Skip to content

Commit

Permalink
Simplify flags query
Browse files Browse the repository at this point in the history
  • Loading branch information
OrdinaryJellyfish committed Nov 22, 2023
1 parent e00ab05 commit e20db6e
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions extensions/flags/src/Api/Controller/ListFlagsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,11 @@ protected function data(ServerRequestInterface $request, Document $document): it
$include[] = 'post.user.groups';
}

$primaries = Flag::whereVisibleTo($actor)
->groupBy('post_id')
->orderBy('created_at', 'DESC')
->skip($offset)
->take($limit + 1);

$flags = Flag::whereVisibleTo($actor)
->select('flags.*')
->joinSub($primaries, 'p', 'flags.id', '=', 'p.id')
->latest()
->latest('flags.created_at')
->groupBy('post_id')
->limit($limit + 1)
->offset($offset)
->get();

$this->loadRelations($flags, $include, $request);
Expand Down

0 comments on commit e20db6e

Please sign in to comment.