##// END OF EJS Templates
pull-requests: use count only for comments related to display grids on my account and repo view.
marcink -
r4506:ed3be682 stable
parent child Browse files
Show More
@@ -734,8 +734,8 b' class MyAccountView(BaseAppView, DataGri'
734 734 comments_model = CommentsModel()
735 735 for pr in pull_requests:
736 736 repo_id = pr.target_repo_id
737 comments = comments_model.get_all_comments(
738 repo_id, pull_request=pr)
737 comments_count = comments_model.get_all_comments(
738 repo_id, pull_request=pr, count_only=True)
739 739 owned = pr.user_id == self._rhodecode_user.user_id
740 740
741 741 data.append({
@@ -760,8 +760,8 b' class MyAccountView(BaseAppView, DataGri'
760 760 'author': _render('pullrequest_author',
761 761 pr.author.full_contact, ),
762 762 'author_raw': pr.author.full_name,
763 'comments': _render('pullrequest_comments', len(comments)),
764 'comments_raw': len(comments),
763 'comments': _render('pullrequest_comments', comments_count),
764 'comments_raw': comments_count,
765 765 'closed': pr.is_closed(),
766 766 'owned': owned
767 767 })
@@ -105,8 +105,8 b' class RepoPullRequestsView(RepoAppView, '
105 105 data = []
106 106 comments_model = CommentsModel()
107 107 for pr in pull_requests:
108 comments = comments_model.get_all_comments(
109 self.db_repo.repo_id, pull_request=pr)
108 comments_count = comments_model.get_all_comments(
109 self.db_repo.repo_id, pull_request=pr, count_only=True)
110 110
111 111 data.append({
112 112 'name': _render('pullrequest_name',
@@ -127,8 +127,8 b' class RepoPullRequestsView(RepoAppView, '
127 127 'author': _render('pullrequest_author',
128 128 pr.author.full_contact, ),
129 129 'author_raw': pr.author.full_name,
130 'comments': _render('pullrequest_comments', len(comments)),
131 'comments_raw': len(comments),
130 'comments': _render('pullrequest_comments', comments_count),
131 'comments_raw': comments_count,
132 132 'closed': pr.is_closed(),
133 133 })
134 134
@@ -541,17 +541,20 b' class CommentsModel(BaseModel):'
541 541
542 542 return comment
543 543
544 def get_all_comments(self, repo_id, revision=None, pull_request=None):
544 def get_all_comments(self, repo_id, revision=None, pull_request=None, count_only=False):
545 545 q = ChangesetComment.query()\
546 546 .filter(ChangesetComment.repo_id == repo_id)
547 547 if revision:
548 548 q = q.filter(ChangesetComment.revision == revision)
549 549 elif pull_request:
550 550 pull_request = self.__get_pull_request(pull_request)
551 q = q.filter(ChangesetComment.pull_request == pull_request)
551 q = q.filter(ChangesetComment.pull_request_id == pull_request.pull_request_id)
552 552 else:
553 553 raise Exception('Please specify commit or pull_request')
554 554 q = q.order_by(ChangesetComment.created_on)
555 if count_only:
556 return q.count()
557
555 558 return q.all()
556 559
557 560 def get_url(self, comment, request=None, permalink=False, anchor=None):
General Comments 0
You need to be logged in to leave comments. Login now