From 1d213dc1fa4b45280196457c61a1c36c396a602c Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 23 Oct 2017 15:04:06 -0700 Subject: [PATCH] Clean up virtual "_ft_rank" column for query construction of Ferret objects Summary: Ref T12974. Ferret object queries SELECT a virtual "_ft_rank" column for relevance ordering. Currently, they always SELECT this column. That's fine and doesn't hurt anything, but makes developing and debugging things kind of a pain since every query has this `, blah blah _ft_rank` junk. Instead, construct this column only if we're actually going to use it. Mostly, this cleans up DarkConsole / query logs a bit. Test Plan: Viewed normal query results on various pages, viewed global search results, ordered Maniphest tasks by normal stuff and by "Relevance". Viewed DarkConsole, saw no more "_ft_rank" junk on normal pages. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T12974 Differential Revision: https://secure.phabricator.com/D18728 --- .../policy/PhabricatorCursorPagedPolicyAwareQuery.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php b/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php index 19d6ba07f4..63daa6df79 100644 --- a/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php +++ b/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php @@ -1565,6 +1565,13 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery return $select; } + $vector = $this->getOrderVector(); + if (!$vector->containsKey('rank')) { + // We only need to SELECT the virtual "_ft_rank" column if we're + // actually sorting the results by rank. + return $select; + } + if (!$this->ferretEngine) { $select[] = '0 _ft_rank'; return $select;