Make trainee maintainers three times as likely to be picked

Trainee maintainers count as reviewers, but should get more reviews than
most reviewers, as they need practice to become a maintainer. This makes
them three times as likely to be picked (compared to another reviewer;
compared to before, it's roughly twice as likely at the current numbers
for each).

Also, switch to `Array#sample` because I think it looks nicer.
This commit is contained in:
Sean McGivern 2019-04-05 11:20:44 +01:00
parent 0b7f904635
commit dea1171724

View file

@ -31,13 +31,15 @@ MARKDOWN
def spin(team, project, category)
reviewers = team.select { |member| member.reviewer?(project, category) }
traintainers = team.select { |member| member.traintainer?(project, category) }
maintainers = team.select { |member| member.maintainer?(project, category) }
# TODO: filter out people who are currently not in the office
# TODO: take CODEOWNERS into account?
reviewer = reviewers[rand(reviewers.size)]
maintainer = maintainers[rand(maintainers.size)]
# Make traintainers have triple the chance to be picked as a reviewer
reviewer = (reviewers + traintainers + traintainers).sample
maintainer = maintainers.sample
"| #{helper.label_for_category(category)} | #{reviewer&.markdown_name} | #{maintainer&.markdown_name} |"
end