2020use Cog \Laravel \Love \ReactionType \Models \ReactionType ;
2121use Illuminate \Console \Command ;
2222use Illuminate \Contracts \Bus \Dispatcher as DispatcherInterface ;
23+ use Illuminate \Contracts \Config \Repository as AppConfigRepositoryInterface ;
2324use Illuminate \Database \Eloquent \Relations \Relation ;
2425use Symfony \Component \Console \Attribute \AsCommand ;
2526use Symfony \Component \Console \Input \InputOption ;
@@ -62,6 +63,7 @@ protected function getOptions(): array
6263 */
6364 public function handle (
6465 DispatcherInterface $ dispatcher ,
66+ AppConfigRepositoryInterface $ appConfigRepository ,
6567 ): int {
6668 $ this ->dispatcher = $ dispatcher ;
6769
@@ -75,12 +77,15 @@ public function handle(
7577
7678 $ queueConnectionName = $ this ->option ('queue-connection ' );
7779 if ($ queueConnectionName === null || $ queueConnectionName === '' ) {
78- $ queueConnectionName = ' sync ' ;
80+ $ queueConnectionName = $ appConfigRepository -> get ( ' queue.default ' ) ;
7981 }
8082
83+ $ this ->warn (
84+ "Rebuilding reaction aggregates using ` $ queueConnectionName` queue connection. "
85+ );
86+
8187 $ reactants = $ this ->collectReactants ($ reactableType );
8288
83- $ this ->warnProcessingStartedOn ($ queueConnectionName );
8489 $ this ->getOutput ()->progressStart ($ reactants ->count ());
8590 foreach ($ reactants as $ reactant ) {
8691 $ this ->dispatcher ->dispatch (
@@ -166,22 +171,4 @@ private function collectReactants(
166171
167172 return $ reactantsQuery ->get ();
168173 }
169-
170- /**
171- * Write warning output that processing has been started.
172- */
173- private function warnProcessingStartedOn (
174- ?string $ queueConnectionName ,
175- ): void {
176- if ($ queueConnectionName === 'sync ' ) {
177- $ message = 'Rebuilding reaction aggregates synchronously. ' ;
178- } else {
179- $ message = sprintf (
180- 'Adding rebuild reaction aggregates to the `%s` queue connection. ' ,
181- $ queueConnectionName
182- );
183- }
184-
185- $ this ->warn ($ message );
186- }
187174}
0 commit comments