changeset 5931:69750b518137

admin: simplify query for owned and followed repositories
author Mads Kiilerich <madski@unity3d.com>
date Mon, 23 May 2016 18:02:33 +0200
parents db2e1fb6aec7
children 73e44865f204
files kallithea/controllers/admin/my_account.py
diffstat 1 files changed, 5 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/controllers/admin/my_account.py	Mon May 23 18:02:33 2016 +0200
+++ b/kallithea/controllers/admin/my_account.py	Mon May 23 18:02:33 2016 +0200
@@ -75,16 +75,15 @@
     def _load_my_repos_data(self, watched=False):
         if watched:
             admin = False
-            repos_list = [x.follows_repository for x in
-                          Session().query(UserFollowing).filter(
-                              UserFollowing.user_id ==
-                              self.authuser.user_id).all()]
+            repos_list = Session().query(Repository) \
+                         .join(UserFollowing) \
+                         .filter(UserFollowing.user_id ==
+                                 self.authuser.user_id).all()
         else:
             admin = True
             repos_list = Session().query(Repository) \
                          .filter(Repository.user_id ==
-                                 self.authuser.user_id) \
-                         .order_by(func.lower(Repository.repo_name)).all()
+                                 self.authuser.user_id).all()
 
         repos_data = RepoModel().get_repos_as_dict(repos_list=repos_list,
                                                    admin=admin)