1
0
mirror of https://github.com/flarum/core.git synced 2025-07-24 10:11:43 +02:00

Remove total results from discussion searching

It’s too inefficient (requires a whole table scan) to do a query like:
select count(*) from discussions where [conditions determining
visibility]
This commit is contained in:
Toby Zerner
2015-06-16 16:58:10 +09:30
parent 385ebf012d
commit 320180efc4
3 changed files with 3 additions and 17 deletions

View File

@@ -74,11 +74,7 @@ class IndexAction extends SerializeCollectionAction
$load = array_merge($request->include, ['state']);
$results = $this->searcher->search($criteria, $request->limit, $request->offset, $load);
if (($total = $results->getTotal()) !== null) {
$response->content->addMeta('total', $total);
}
static::addPaginationLinks($response, $request, route('flarum.api.discussions.index'), $total ?: $results->areMoreResults());
static::addPaginationLinks($response, $request, route('flarum.api.discussions.index'), $results->areMoreResults());
return $results->getDiscussions();
}