##// END OF EJS Templates
optimized filtering on journal
marcink -
r1019:e4b7cfeb beta
parent child Browse files
Show More
@@ -64,13 +64,22 b' class JournalController(BaseController):'
64 user_ids = [x.follows_user.user_id for x in c.following
64 user_ids = [x.follows_user.user_id for x in c.following
65 if x.follows_user is not None]
65 if x.follows_user is not None]
66
66
67 journal = self.sa.query(UserLog)\
67 filtering_criterion = None
68 .filter(or_(
69 UserLog.repository_id.in_(repo_ids),
70 UserLog.user_id.in_(user_ids),
71 ))\
72 .order_by(UserLog.action_date.desc())
73
68
69 if repo_ids and user_ids:
70 filtering_criterion = or_(UserLog.repository_id.in_(repo_ids),
71 UserLog.user_id.in_(user_ids))
72 if repo_ids and not user_ids:
73 filtering_criterion = UserLog.repository_id.in_(repo_ids)
74 if not repo_ids and user_ids:
75 filtering_criterion = UserLog.user_id.in_(user_ids)
76
77 if filtering_criterion is not None:
78 journal = self.sa.query(UserLog)\
79 .filter(filtering_criterion)\
80 .order_by(UserLog.action_date.desc())
81 else:
82 journal = []
74
83
75 p = int(request.params.get('page', 1))
84 p = int(request.params.get('page', 1))
76 c.journal_pager = Page(journal, page=p, items_per_page=10)
85 c.journal_pager = Page(journal, page=p, items_per_page=10)
General Comments 0
You need to be logged in to leave comments. Login now