Commit e3346db0 authored by Simon Chabot's avatar Simon Chabot
Browse files

feat: assign merge request in a randomized order

so that older merge request also get a chance to be reviewed
parent 21cdfc52da09
Pipeline #15617 passed with stage
in 27 seconds
...@@ -21,8 +21,7 @@ ...@@ -21,8 +21,7 @@
import os import os
from argparse import ArgumentParser from argparse import ArgumentParser
from itertools import chain from random import choice, shuffle
from random import choice
from datetime import datetime, timedelta from datetime import datetime, timedelta
import yaml import yaml
...@@ -137,27 +136,29 @@ class ReviewAssigner: ...@@ -137,27 +136,29 @@ class ReviewAssigner:
print(f"{user.name} has been assigned to {merge_request.title}") print(f"{user.name} has been assigned to {merge_request.title}")
def all_reviews_to_do(self): def all_reviews_to_do(self):
mr_with_to_review_tag = self.cnx.mergerequests.list( merge_requests = self.cnx.mergerequests.list(
labels=TO_REVIEW_LABEL, labels=TO_REVIEW_LABEL,
state="opened", state="opened",
wip="no", wip="no",
scope="all", scope="all",
assignee_id="None", assignee_id="None",
as_list=False,
all=True, all=True,
) )
mr_with_no_tags = self.cnx.mergerequests.list( merge_requests.extend(
labels="None", self.cnx.mergerequests.list(
state="opened", labels="None",
wip="no", state="opened",
scope="all", wip="no",
assignee_id="None", scope="all",
as_list=False, assignee_id="None",
all=True, all=True,
)
) )
for merge_request in chain(mr_with_to_review_tag, mr_with_no_tags): shuffle(merge_requests)
for merge_request in merge_requests:
project = self.cnx.projects.get(merge_request.project_id) project = self.cnx.projects.get(merge_request.project_id)
if CLIENT_PROJECT_TAG in project.tag_list: if CLIENT_PROJECT_TAG in project.tag_list:
# it's a client project. Let's assume that someone will take # it's a client project. Let's assume that someone will take
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment