mirror of
https://github.com/flarum/framework.git
synced 2025-03-31 20:55:15 +08:00
Performance: Assign parent discussions to posts so they don't have to be reloaded
This commit is contained in:
parent
3c80612d80
commit
a28dbccf1a
@ -153,7 +153,7 @@ class PostRepository
|
||||
{
|
||||
$discussions = $this->getDiscussionsForPosts($ids, $actor);
|
||||
|
||||
return Post::whereIn('id', $ids)
|
||||
$posts = Post::whereIn('id', $ids)
|
||||
->where(function ($query) use ($discussions, $actor) {
|
||||
foreach ($discussions as $discussion) {
|
||||
$query->orWhere(function ($query) use ($discussion, $actor) {
|
||||
@ -165,6 +165,12 @@ class PostRepository
|
||||
|
||||
$query->orWhereRaw('FALSE');
|
||||
});
|
||||
|
||||
foreach ($posts as $post) {
|
||||
$post->discussion = $discussions->find($post->discussion_id);
|
||||
}
|
||||
|
||||
return $posts;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user