[LNT] r267387 - [search] Correctly order results
James Molloy via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 25 01:58:54 PDT 2016
Author: jamesm
Date: Mon Apr 25 03:58:53 2016
New Revision: 267387
URL: http://llvm.org/viewvc/llvm-project?rev=267387&view=rev
Log:
[search] Correctly order results
We were ordering by llvm_project_revision DESC, which doesn't work because it's actually a VARCHAR field and we were getting lexicographic ordering.
Instead, order by Run.id DESC which will show the most recent runs first.
Modified:
lnt/trunk/lnt/server/db/search.py
lnt/trunk/tests/server/db/search.py
Modified: lnt/trunk/lnt/server/db/search.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/db/search.py?rev=267387&r1=267386&r2=267387&view=diff
==============================================================================
--- lnt/trunk/lnt/server/db/search.py (original)
+++ lnt/trunk/lnt/server/db/search.py Mon Apr 25 03:58:53 2016
@@ -50,13 +50,13 @@ def _naive_search_for_run(ts, query, num
q = ts.query(ts.Run) \
.filter(ts.Run.machine_id.in_(machines)) \
- .filter(ts.Run.order_id == ts.Order.id)
+ .filter(ts.Run.order_id == ts.Order.id) \
+ .filter(llvm_project_revision_col != None)
if order_queries:
oq = '%' + str(order_queries[0]) + '%'
- q = q.filter(llvm_project_revision_col.like(oq))
+ q = q.filter(llvm_project_revision_col.like(oq))
- return q.order_by(llvm_project_revision_col.desc()).limit(num_results).all()
-
+ return q.order_by(ts.Run.id.desc()).limit(num_results).all()
def search(ts, query,
num_results=8, default_machine=None):
Modified: lnt/trunk/tests/server/db/search.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/server/db/search.py?rev=267387&r1=267386&r2=267387&view=diff
==============================================================================
--- lnt/trunk/tests/server/db/search.py (original)
+++ lnt/trunk/tests/server/db/search.py Mon Apr 25 03:58:53 2016
@@ -15,6 +15,7 @@ class SearchTest(unittest.TestCase):
master_path = os.path.join(base_path, 'Inputs/lnt_v0.4.0_filled_instance')
slave_path = os.path.join(tempfile.mkdtemp(), 'lnt')
shutil.copytree(master_path, slave_path)
+
instance = lnt.server.instance.Instance.frompath(slave_path)
config = instance.config
@@ -22,6 +23,10 @@ class SearchTest(unittest.TestCase):
('machine1', '5625'),
('machine2', '6512'),
('machine2', '7623'),
+ ('machine3', '65'),
+ ('machine3', '6512'),
+ ('machine3', '7623'),
+ ('machine3', '11324'),
('supermachine', '1324'),
('supermachine', '7623')]
@@ -87,9 +92,12 @@ class SearchTest(unittest.TestCase):
def test_default_order(self):
ts = self.db.testsuite.get('nts')
- results = self._mangleResults(search(ts, 'machi ne2'))
+ results = self._mangleResults(search(ts, 'machi ne3'))
self.assertEqual(results, [
- ('machine2', '7623'), ('machine2', '6512')
+ ('machine3', '11324'),
+ ('machine3', '7623'),
+ ('machine3', '6512'),
+ ('machine3', '65')
])
def test_default_machine(self):
More information about the llvm-commits
mailing list