From 1ac2abcab598e0503e895530e1ef8d5291a377e2 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sun, 13 Oct 2019 20:35:29 +0100 Subject: [PATCH] Only create tasks if I was asked to review them --- actioner/scheduler/todoist_repo_prs.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/actioner/scheduler/todoist_repo_prs.py b/actioner/scheduler/todoist_repo_prs.py index 99bcbc4..dc02721 100644 --- a/actioner/scheduler/todoist_repo_prs.py +++ b/actioner/scheduler/todoist_repo_prs.py @@ -20,6 +20,14 @@ def get_my_review(me, pr: PullRequest): return review +def get_my_review_requested(me, pr: PullRequest) -> bool: + reviewing_users, _ = pr.get_review_requests() + for user in reviewing_users: + if user.login == me.login: + return True + return False + + def todoist_repo_prs(): todoist = get_todoist_client() me = github.get_user() @@ -64,7 +72,11 @@ def todoist_repo_prs(): todoist.items.unarchive(existing_task_id) todoist.items.uncomplete(existing_task_id) continue - elif my_review and my_review.commit_id != pr.head.sha: + elif ( + get_my_review_requested(me, pr) + and my_review + and my_review.commit_id != pr.head.sha + ): logger.info("Creating task to review '{}'".format(pr.title)) existing_task_id = todoist.items.add( pr_to_task_name(pr), project_id=project_id