Skip to content

Commit

Permalink
fix(backend): Create new query for each category (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
cleptric authored Jun 26, 2023
1 parent db66329 commit 2dfc33c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Command/WeeklyReportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@ public function execute(Arguments $args, ConsoleIo $io)
'created >=' => new FrozenTime('1 week ago'),
]);

$query = $usersTable->find();

$topSenders = $query
$topSendersQuery = $usersTable->find();
$topSenders = $topSendersQuery
->select([
'sent_count' => $sentCountQuery,
])
Expand All @@ -79,11 +78,12 @@ public function execute(Arguments $args, ConsoleIo $io)
'Users.role !=' => User::ROLE_SERVICE,
])
->group(['Users.id'])
->order(['sent_count' => $query->newExpr('DESC NULLS LAST')])
->order(['sent_count' => $topSendersQuery->newExpr('DESC NULLS LAST')])
->limit(5)
->enableAutoFields(true);

$topReceivers = $query
$topReceiversQuery = $usersTable->find();
$topReceivers = $topReceiversQuery
->select([
'received_count' => $reivedCountQuery,
])
Expand All @@ -94,7 +94,7 @@ public function execute(Arguments $args, ConsoleIo $io)
'Users.role !=' => User::ROLE_SERVICE,
])
->group(['Users.id'])
->order(['received_count' => $query->newExpr('DESC NULLS LAST')])
->order(['received_count' => $topReceiversQuery->newExpr('DESC NULLS LAST')])
->limit(5)
->enableAutoFields(true);

Expand Down

0 comments on commit 2dfc33c

Please sign in to comment.