From e20db6e89f63de3813c7eb3514f5e333e2541791 Mon Sep 17 00:00:00 2001 From: Tristian Kelly Date: Wed, 22 Nov 2023 13:28:54 -0600 Subject: [PATCH] Simplify flags query --- .../src/Api/Controller/ListFlagsController.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/extensions/flags/src/Api/Controller/ListFlagsController.php b/extensions/flags/src/Api/Controller/ListFlagsController.php index 9e49129d09..534d3abe56 100644 --- a/extensions/flags/src/Api/Controller/ListFlagsController.php +++ b/extensions/flags/src/Api/Controller/ListFlagsController.php @@ -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);