Only complete and uncomplete when not already

This commit is contained in:
Jake Howard 2019-02-20 19:47:02 +00:00
parent d2d0f6e291
commit f1464065b5
Signed by: jake
GPG key ID: 57AFB45680EDD477

View file

@ -49,7 +49,7 @@ def todoist_assigned_issues():
todoist.items.delete([existing_task_id])
continue
elif issue.state == 'closed' and existing_task_id is not None:
elif issue.state == 'closed' and existing_task_id is not None and not todoist.items.get_by_id(existing_task_id)['checked']:
logger.info("Completing task for '{}'".format(issue.title))
todoist.items.complete([existing_task_id])
continue
@ -62,6 +62,11 @@ def todoist_assigned_issues():
project_id
)['id']
existing_task = todoist.items.get_by_id(existing_task_id)
if existing_task['checked']:
logger.info("Re-opening task '{}'".format(issue.title))
todoist.items.uncomplete([existing_task_id])
existing_task.update(
content=issue_to_task_name(issue),
priority=get_status_for_issue(issue)