Delete items i'm no longer assigned to

This commit is contained in:
Jake Howard 2019-02-17 12:29:44 +00:00
parent 9fa2c7532c
commit 78b7d545e2
Signed by: jake
GPG key ID: 57AFB45680EDD477
2 changed files with 13 additions and 1 deletions

View file

@ -7,7 +7,7 @@ from .todoist_assigned_issues import todoist_assigned_issues
def create_scheduler(): def create_scheduler():
scheduler = AsyncIOScheduler() scheduler = AsyncIOScheduler()
scheduler.add_job(todoist_assigned_issues, 'interval', minutes=15) scheduler.add_job(todoist_assigned_issues)
return scheduler return scheduler

View file

@ -1,3 +1,4 @@
import re
from typing import Dict from typing import Dict
from github import Issue from github import Issue
@ -15,6 +16,8 @@ LABEL_TO_STATUS = {
'should have': 2 'should have': 2
} }
ISSUE_NUMBER_RE = re.compile(r"\[#(\d+?)\]")
def get_status_for_issue(issue: Issue) -> int: def get_status_for_issue(issue: Issue) -> int:
priorities = { priorities = {
@ -70,4 +73,13 @@ def todoist_assigned_issues():
if existing_task_id is not None: if existing_task_id is not None:
todoist.items.complete([existing_task_id]) todoist.items.complete([existing_task_id])
for existing_task_id, existing_task_content in existing_tasks.items():
if repo.html_url not in existing_task_content:
continue
issue_number = ISSUE_NUMBER_RE.match(existing_task_content).group(1)
issue = repo.get_issue(int(issue_number))
assignees = {assignee.login for assignee in issue.assignees}
if me.login not in assignees:
todoist.items.delete([existing_task_id])
todoist.commit() todoist.commit()