Skip to content

Commit

Permalink
Eager load tags relation in discussion, posts and flags listing endpo…
Browse files Browse the repository at this point in the history
…ints (#125)

* Eager load tags relation when listing posts & discussions
* Eager load ListFlags post.discussion.tags relation
  • Loading branch information
SychO9 authored Mar 25, 2021
1 parent ece541e commit b2f205e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion extend.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Flarum\Discussion\Filter\DiscussionFilterer;
use Flarum\Discussion\Search\DiscussionSearcher;
use Flarum\Extend;
use Flarum\Flags\Api\Controller\ListFlagsController;
use Flarum\Flags\Flag;
use Flarum\Tags\Access;
use Flarum\Tags\Api\Controller;
Expand Down Expand Up @@ -62,8 +63,15 @@
return $serializer->getActor()->can('tag', $model);
}),

(new Extend\ApiController(FlarumController\ListPostsController::class))
->load('discussion.tags'),

(new Extend\ApiController(ListFlagsController::class))
->load('post.discussion.tags'),

(new Extend\ApiController(FlarumController\ListDiscussionsController::class))
->addInclude(['tags', 'tags.state']),
->addInclude(['tags', 'tags.state'])
->load('tags'),

(new Extend\ApiController(FlarumController\ShowDiscussionController::class))
->addInclude(['tags', 'tags.state']),
Expand Down

0 comments on commit b2f205e

Please sign in to comment.