You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2013/06/20 18:30:46 UTC

[3/3] git commit: [#6324] Reduce ProjectRole queries when getting user's projects

[#6324] Reduce ProjectRole queries when getting user's projects

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/78f7e4b9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/78f7e4b9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/78f7e4b9

Branch: refs/heads/cj/6324
Commit: 78f7e4b9682f16bb318986ac79ee1838b8f4d443
Parents: 79003b9
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Thu Jun 20 16:07:48 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Thu Jun 20 16:29:21 2013 +0000

----------------------------------------------------------------------
 Allura/allura/model/auth.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/78f7e4b9/Allura/allura/model/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index 38890fc..e7f045b 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -651,8 +651,8 @@ class User(MappedClass, ActivityNode, ActivityObject):
 
     def my_projects(self):
         '''Find the projects for which this user has a named role.'''
-        reaching_role_ids = g.credentials.user_roles(user_id=self._id).reaching_ids_set
-        reaching_roles = [ ProjectRole.query.get(_id=i) for i in reaching_role_ids ]
+        reaching_role_ids = list(g.credentials.user_roles(user_id=self._id).reaching_ids_set)
+        reaching_roles = ProjectRole.query.find({'_id': {'$in': reaching_role_ids}}).all()
         named_roles = [ r for r in reaching_roles
                                 if r.name and r.project and not r.project.deleted ]
         seen_project_ids = set()