Show More
@@ -734,8 +734,8 b' class MyAccountView(BaseAppView, DataGri' | |||||
734 | comments_model = CommentsModel() |
|
734 | comments_model = CommentsModel() | |
735 | for pr in pull_requests: |
|
735 | for pr in pull_requests: | |
736 | repo_id = pr.target_repo_id |
|
736 | repo_id = pr.target_repo_id | |
737 | comments = comments_model.get_all_comments( |
|
737 | comments_count = comments_model.get_all_comments( | |
738 | repo_id, pull_request=pr) |
|
738 | repo_id, pull_request=pr, count_only=True) | |
739 | owned = pr.user_id == self._rhodecode_user.user_id |
|
739 | owned = pr.user_id == self._rhodecode_user.user_id | |
740 |
|
740 | |||
741 | data.append({ |
|
741 | data.append({ | |
@@ -760,8 +760,8 b' class MyAccountView(BaseAppView, DataGri' | |||||
760 | 'author': _render('pullrequest_author', |
|
760 | 'author': _render('pullrequest_author', | |
761 | pr.author.full_contact, ), |
|
761 | pr.author.full_contact, ), | |
762 | 'author_raw': pr.author.full_name, |
|
762 | 'author_raw': pr.author.full_name, | |
763 |
'comments': _render('pullrequest_comments', |
|
763 | 'comments': _render('pullrequest_comments', comments_count), | |
764 |
'comments_raw': |
|
764 | 'comments_raw': comments_count, | |
765 | 'closed': pr.is_closed(), |
|
765 | 'closed': pr.is_closed(), | |
766 | 'owned': owned |
|
766 | 'owned': owned | |
767 | }) |
|
767 | }) |
@@ -105,8 +105,8 b' class RepoPullRequestsView(RepoAppView, ' | |||||
105 | data = [] |
|
105 | data = [] | |
106 | comments_model = CommentsModel() |
|
106 | comments_model = CommentsModel() | |
107 | for pr in pull_requests: |
|
107 | for pr in pull_requests: | |
108 | comments = comments_model.get_all_comments( |
|
108 | comments_count = comments_model.get_all_comments( | |
109 | self.db_repo.repo_id, pull_request=pr) |
|
109 | self.db_repo.repo_id, pull_request=pr, count_only=True) | |
110 |
|
110 | |||
111 | data.append({ |
|
111 | data.append({ | |
112 | 'name': _render('pullrequest_name', |
|
112 | 'name': _render('pullrequest_name', | |
@@ -127,8 +127,8 b' class RepoPullRequestsView(RepoAppView, ' | |||||
127 | 'author': _render('pullrequest_author', |
|
127 | 'author': _render('pullrequest_author', | |
128 | pr.author.full_contact, ), |
|
128 | pr.author.full_contact, ), | |
129 | 'author_raw': pr.author.full_name, |
|
129 | 'author_raw': pr.author.full_name, | |
130 |
'comments': _render('pullrequest_comments', |
|
130 | 'comments': _render('pullrequest_comments', comments_count), | |
131 |
'comments_raw': |
|
131 | 'comments_raw': comments_count, | |
132 | 'closed': pr.is_closed(), |
|
132 | 'closed': pr.is_closed(), | |
133 | }) |
|
133 | }) | |
134 |
|
134 |
@@ -541,17 +541,20 b' class CommentsModel(BaseModel):' | |||||
541 |
|
541 | |||
542 | return comment |
|
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 | q = ChangesetComment.query()\ |
|
545 | q = ChangesetComment.query()\ | |
546 | .filter(ChangesetComment.repo_id == repo_id) |
|
546 | .filter(ChangesetComment.repo_id == repo_id) | |
547 | if revision: |
|
547 | if revision: | |
548 | q = q.filter(ChangesetComment.revision == revision) |
|
548 | q = q.filter(ChangesetComment.revision == revision) | |
549 | elif pull_request: |
|
549 | elif pull_request: | |
550 | pull_request = self.__get_pull_request(pull_request) |
|
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 | else: |
|
552 | else: | |
553 | raise Exception('Please specify commit or pull_request') |
|
553 | raise Exception('Please specify commit or pull_request') | |
554 | q = q.order_by(ChangesetComment.created_on) |
|
554 | q = q.order_by(ChangesetComment.created_on) | |
|
555 | if count_only: | |||
|
556 | return q.count() | |||
|
557 | ||||
555 | return q.all() |
|
558 | return q.all() | |
556 |
|
559 | |||
557 | def get_url(self, comment, request=None, permalink=False, anchor=None): |
|
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