← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad/snap-git-url-optimise into lp:launchpad

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/snap-git-url-optimise into lp:launchpad.

Commit message:
Optimise slow query in SnapSet.findByURL.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/snap-git-url-optimise/+merge/312512
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/snap-git-url-optimise into lp:launchpad.
=== modified file 'lib/lp/snappy/model/snap.py'
--- lib/lp/snappy/model/snap.py	2016-12-02 12:53:41 +0000
+++ lib/lp/snappy/model/snap.py	2016-12-05 23:11:59 +0000
@@ -18,6 +18,7 @@
     LeftJoin,
     Not,
     Or,
+    Select,
     )
 from storm.locals import (
     Bool,
@@ -754,9 +755,9 @@
             else:
                 visibility_clause = Or(
                     Snap.private == False,
-                    And(
-                        TeamParticipation.person == visible_by_user,
-                        TeamParticipation.teamID == Snap.owner_id))
+                    Snap.owner_id.is_in(Select(
+                        TeamParticipation.teamID,
+                        TeamParticipation.person == visible_by_user)))
         clauses.append(visibility_clause)
         return IStore(Snap).find(Snap, *clauses).config(distinct=True)
 


Follow ups