Commit 79ce1e37 authored by Simon Chabot's avatar Simon Chabot

feat: assignbot choose a reviewer and not an assignee

closes #4
parent 7817307e003a
......@@ -47,13 +47,13 @@ Do you think it should still be merged?
Thank you for your time.
"""
def all_reviews(cnx, assignee_id="None"):
def all_reviews(cnx, reviewer_id="None"):
merge_requests = cnx.mergerequests.list(
labels=TO_REVIEW_LABEL,
state="opened",
wip="no",
scope="all",
assignee_id=assignee_id,
reviewer_id=reviewer_id,
all=True,
)
......@@ -63,7 +63,7 @@ def all_reviews(cnx, assignee_id="None"):
state="opened",
wip="no",
scope="all",
assignee_id=assignee_id,
reviewer_id=reviewer_id,
all=True,
)
)
......@@ -173,7 +173,7 @@ class ReviewAssigner:
try:
self.cnx.http_put(
f"/projects/{merge_request.project_id}/merge_requests/{merge_request.iid}",
query_data={"assignee_id": user.id},
query_data={"reviewer_ids": [user.id]},
)
except GitlabHttpError:
print(
......@@ -189,13 +189,12 @@ class ReviewAssigner:
)
print(f"{user.name} has been assigned to {merge_request.title}")
def all_reviews_to_do(self):
return all_reviews(self.cnx, assignee_id="None")
return all_reviews(self.cnx, reviewer_id="None")
def all_pending_reviews_older_than(self, older_than):
now = datetime.now(timezone.utc)
for mr in all_reviews(self.cnx, assignee_id="Any"):
for mr in all_reviews(self.cnx, reviewer_id="Any"):
mr_last_update = datetime.fromisoformat(
mr.updated_at.replace("Z", "+00:00")
)
......
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