##// END OF EJS Templates
default-reviewers: fixed voting rule calculation on user-group. The previous...
marcink -
r2960:545905e2 default
parent child Browse files
Show More
@@ -4323,10 +4323,15 b' class RepoReviewRule(Base, BaseModel):'
4323
4323
4324 return users
4324 return users
4325
4325
4326 def user_group_vote_rule(self):
4326 def user_group_vote_rule(self, user_id):
4327
4327 rules = []
4328 rules = []
4328 if self.rule_user_groups:
4329 if not self.rule_user_groups:
4329 for user_group in self.rule_user_groups:
4330 return rules
4331
4332 for user_group in self.rule_user_groups:
4333 user_group_members = [x.user_id for x in user_group.users_group.members]
4334 if user_id in user_group_members:
4330 rules.append(user_group)
4335 rules.append(user_group)
4331 return rules
4336 return rules
4332
4337
@@ -490,11 +490,12 b' class PullRequestModel(BaseModel):'
490 rule_id = list(rules)[0] if rules else None
490 rule_id = list(rules)[0] if rules else None
491 rule = RepoReviewRule.get(rule_id) if rule_id else None
491 rule = RepoReviewRule.get(rule_id) if rule_id else None
492 if rule:
492 if rule:
493 review_group = rule.user_group_vote_rule()
493 review_group = rule.user_group_vote_rule(user_id)
494 # we check if this particular reviewer is member of a voting group
494 if review_group:
495 if review_group:
495 # NOTE(marcink):
496 # NOTE(marcink):
496 # again, can be that user is member of more,
497 # can be that user is member of more but we pick the first same,
497 # but we pick the first same, as default reviewers algo
498 # same as default reviewers algo
498 review_group = review_group[0]
499 review_group = review_group[0]
499
500
500 rule_data = {
501 rule_data = {
@@ -506,6 +507,8 b' class PullRequestModel(BaseModel):'
506 review_group.users_group.users_group_name,
507 review_group.users_group.users_group_name,
507 'rule_user_group_members':
508 'rule_user_group_members':
508 [x.user.username for x in review_group.users_group.members],
509 [x.user.username for x in review_group.users_group.members],
510 'rule_user_group_members_id':
511 [x.user.user_id for x in review_group.users_group.members],
509 }
512 }
510 # e.g {'vote_rule': -1, 'mandatory': True}
513 # e.g {'vote_rule': -1, 'mandatory': True}
511 rule_data.update(review_group.rule_data())
514 rule_data.update(review_group.rule_data())
General Comments 0
You need to be logged in to leave comments. Login now