[LNT] r308861 - Simplify joinedload usage; NFC

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 23 19:37:17 PDT 2017


Author: matze
Date: Sun Jul 23 19:37:16 2017
New Revision: 308861

URL: http://llvm.org/viewvc/llvm-project?rev=308861&view=rev
Log:
Simplify joinedload usage; NFC

Modified:
    lnt/trunk/lnt/server/ui/api.py
    lnt/trunk/lnt/server/ui/views.py

Modified: lnt/trunk/lnt/server/ui/api.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/api.py?rev=308861&r1=308860&r2=308861&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/api.py (original)
+++ lnt/trunk/lnt/server/ui/api.py Sun Jul 23 19:37:16 2017
@@ -113,18 +113,16 @@ class Machine(Resource):
     @staticmethod
     def get(machine_id):
         ts = request.get_testsuite()
-        this_machine = Machine._get_machine(machine_id)
+        machine = Machine._get_machine(machine_id)
         machine_runs = ts.query(ts.Run) \
-            .join(ts.Machine) \
-            .join(ts.Order) \
-            .filter(ts.Machine.id == machine_id) \
-            .options(joinedload('order')) \
+            .filter(ts.Run.machine_id == machine.id) \
+            .options(joinedload(ts.Run.order)) \
             .all()
 
         runs = [run.__json__(flatten_order=True) for run in machine_runs]
 
         result = common_fields_factory()
-        result['machine'] = this_machine
+        result['machine'] = machine
         result['runs'] = runs
         return result
 
@@ -221,10 +219,9 @@ class Run(Resource):
 
         try:
             run = ts.query(ts.Run) \
-                .join(ts.Machine) \
-                .join(ts.Order) \
                 .filter(ts.Run.id == run_id) \
-                .options(joinedload('order')) \
+                .options(joinedload(ts.Run.machine)) \
+                .options(joinedload(ts.Run.order)) \
                 .one()
         except sqlalchemy.orm.exc.NoResultFound:
             abort(404, msg="Did not find run " + str(run_id))

Modified: lnt/trunk/lnt/server/ui/views.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/views.py?rev=308861&r1=308860&r2=308861&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/views.py (original)
+++ lnt/trunk/lnt/server/ui/views.py Sun Jul 23 19:37:16 2017
@@ -187,8 +187,6 @@ def v4_recent_activity():
     # Get the most recent runs in this tag, we just arbitrarily limit to
     # looking at the last 100 submission.
     recent_runs = ts.query(ts.Run) \
-        .join(ts.Order) \
-        .join(ts.Machine) \
         .options(joinedload(ts.Run.order)) \
         .options(joinedload(ts.Run.machine)) \
         .order_by(ts.Run.start_time.desc()).limit(100)
@@ -781,7 +779,7 @@ def v4_graph():
 
         try:
             run = ts.query(ts.Run) \
-                .join(ts.Machine) \
+                .options(joinedload(ts.Run.machine)) \
                 .filter(ts.Run.id == run_id) \
                 .one()
         except:




More information about the llvm-commits mailing list