diff --git a/vrobbler/apps/scrobbles/scrobblers.py b/vrobbler/apps/scrobbles/scrobblers.py index 52435bf..2d49cc9 100644 --- a/vrobbler/apps/scrobbles/scrobblers.py +++ b/vrobbler/apps/scrobbles/scrobblers.py @@ -348,11 +348,16 @@ def todoist_scrobble_task(todoist_task: dict, user_id: int) -> Scrobble: task = Task.find_or_create(title) in_progress_scrobble = Scrobble.objects.filter( - in_progress=True, log__todoist_id=todoist_task.get("todoist_id") + in_progress=True, + log__todoist_id=todoist_task.get("todoist_id"), + task=task, ).first() if in_progress_scrobble: return in_progress_scrobble + if "inprogress" not in todoist_task["todoist_label_list"]: + return todoist_scrobble_task_finish(todoist_task, user_id) + # TODO Should use updated_at from TOdoist, but parsing isn't working scrobble_dict = { "user_id": user_id, diff --git a/vrobbler/apps/tasks/webhooks.py b/vrobbler/apps/tasks/webhooks.py index 88eaf84..8e7473c 100644 --- a/vrobbler/apps/tasks/webhooks.py +++ b/vrobbler/apps/tasks/webhooks.py @@ -60,10 +60,9 @@ def todoist_webhook(request): if not user_id: user_id = 1 - scrobble = None if "completed" in todoist_task["todoist_event"]: scrobble = todoist_scrobble_task_finish(todoist_task, user_id) - elif "inprogress" in todoist_task["todoist_label_list"]: + else: scrobble = todoist_scrobble_task(todoist_task, user_id) if not scrobble: