##// END OF EJS Templates
inline-comments: added helper to properly count inline comments.
marcink -
r1190:e81752c2 default
parent child Browse files
Show More
@@ -200,7 +200,6 b' class ChangesetController(BaseRepoContro'
200
200
201 c.commit_statuses = ChangesetStatus.STATUSES
201 c.commit_statuses = ChangesetStatus.STATUSES
202 c.inline_comments = []
202 c.inline_comments = []
203 c.inline_cnt = 0
204 c.files = []
203 c.files = []
205
204
206 c.statuses = []
205 c.statuses = []
@@ -254,7 +253,8 b' class ChangesetController(BaseRepoContro'
254
253
255 inline_comments = ChangesetCommentsModel().get_inline_comments(
254 inline_comments = ChangesetCommentsModel().get_inline_comments(
256 c.rhodecode_db_repo.repo_id, revision=commit.raw_id)
255 c.rhodecode_db_repo.repo_id, revision=commit.raw_id)
257 c.inline_cnt += len(inline_comments)
256 c.inline_cnt = ChangesetCommentsModel().get_inline_comments_count(
257 inline_comments)
258
258
259 diffset = codeblocks.DiffSet(
259 diffset = codeblocks.DiffSet(
260 repo_name=c.repo_name,
260 repo_name=c.repo_name,
@@ -720,7 +720,9 b' class PullrequestsController(BaseRepoCon'
720 c.inline_comments = cc_model.get_inline_comments(
720 c.inline_comments = cc_model.get_inline_comments(
721 c.rhodecode_db_repo.repo_id,
721 c.rhodecode_db_repo.repo_id,
722 pull_request=pull_request_id)
722 pull_request=pull_request_id)
723 c.inline_cnt = len(c.inline_comments)
723
724 c.inline_cnt = cc_model.get_inline_comments_count(
725 c.inline_comments, version=at_version)
724
726
725 self._load_compare_data(
727 self._load_compare_data(
726 c.pull_request, c.inline_comments, enable_comments=enable_comments)
728 c.pull_request, c.inline_comments, enable_comments=enable_comments)
@@ -354,6 +354,16 b' class ChangesetCommentsModel(BaseModel):'
354 q = self._get_inline_comments_query(repo_id, revision, pull_request)
354 q = self._get_inline_comments_query(repo_id, revision, pull_request)
355 return self._group_comments_by_path_and_line_number(q)
355 return self._group_comments_by_path_and_line_number(q)
356
356
357 def get_inline_comments_count(self, inline_comments, skip_outdated=True,
358 version=None):
359 inline_cnt = 0
360 for fname, per_line_comments in inline_comments.iteritems():
361 for lno, comments in per_line_comments.iteritems():
362 inline_cnt += len(
363 [comm for comm in comments
364 if (not comm.outdated_at_version(version) and skip_outdated)])
365 return inline_cnt
366
357 def get_outdated_comments(self, repo_id, pull_request):
367 def get_outdated_comments(self, repo_id, pull_request):
358 # TODO: johbo: Remove `repo_id`, it is not needed to find the comments
368 # TODO: johbo: Remove `repo_id`, it is not needed to find the comments
359 # of a pull request.
369 # of a pull request.
@@ -810,7 +810,9 b' def assert_inline_comments(pull_request,'
810 if visible is not None:
810 if visible is not None:
811 inline_comments = ChangesetCommentsModel().get_inline_comments(
811 inline_comments = ChangesetCommentsModel().get_inline_comments(
812 pull_request.target_repo.repo_id, pull_request=pull_request)
812 pull_request.target_repo.repo_id, pull_request=pull_request)
813 assert len(inline_comments) == visible
813 inline_cnt = ChangesetCommentsModel().get_inline_comments_count(
814 inline_comments)
815 assert inline_cnt == visible
814 if outdated is not None:
816 if outdated is not None:
815 outdated_comments = ChangesetCommentsModel().get_outdated_comments(
817 outdated_comments = ChangesetCommentsModel().get_outdated_comments(
816 pull_request.target_repo.repo_id, pull_request)
818 pull_request.target_repo.repo_id, pull_request)
General Comments 0
You need to be logged in to leave comments. Login now