Skip to content
Snippets Groups Projects
Unverified Commit 2897d823 authored by Peter Rotich's avatar Peter Rotich Committed by GitHub
Browse files

Merge pull request #4630 from aydreeihn/issue/advanced-search

Issue: Duplicate Search Results
parents 47318a1a ef8b8cc3
Branches
Tags
No related merge requests found
...@@ -77,16 +77,21 @@ $page = ($_GET['p'] && is_numeric($_GET['p']))?$_GET['p']:1; ...@@ -77,16 +77,21 @@ $page = ($_GET['p'] && is_numeric($_GET['p']))?$_GET['p']:1;
$pageNav = new Pagenate(PHP_INT_MAX, $page, PAGE_LIMIT); $pageNav = new Pagenate(PHP_INT_MAX, $page, PAGE_LIMIT);
$tickets = $pageNav->paginateSimple($tickets); $tickets = $pageNav->paginateSimple($tickets);
// Creative twist here. Create a new query copying the query criteria, sort, limit, if (isset($tickets->extra['tables'])) {
// and offset. Then join this new query to the $tickets query and clear the // Creative twist here. Create a new query copying the query criteria, sort, limit,
// criteria, sort, limit, and offset from the outer query. // and offset. Then join this new query to the $tickets query and clear the
$criteria = clone $tickets; // criteria, sort, limit, and offset from the outer query.
$criteria->annotations = $criteria->related = $criteria->aggregated = []; $criteria = clone $tickets;
$tickets->constraints = $tickets->extra = []; $criteria->limit(500);
$tickets = $tickets->filter(['ticket_id__in' => $criteria->values_flat('ticket_id')]) $criteria->annotations = $criteria->related = $criteria->aggregated =
->limit(false)->offset(false)->order_by(false); $criteria->annotations = $criteria->ordering = [];
# Index hint should be used on the $criteria query only $tickets->constraints = $tickets->extra = [];
$tickets->clearOption(QuerySet::OPT_INDEX_HINT); $tickets = $tickets->filter(['ticket_id__in' =>
$criteria->values_flat('ticket_id')]);
# Index hint should be used on the $criteria query only
$tickets->clearOption(QuerySet::OPT_INDEX_HINT);
$tickets->distinct('ticket_id');
}
$count = $queue->getCount($thisstaff) ?: (PAGE_LIMIT*3); $count = $queue->getCount($thisstaff) ?: (PAGE_LIMIT*3);
$pageNav->setTotal($count, true); $pageNav->setTotal($count, true);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment