[scrobbles] Fix double scrobbling tasks

This commit is contained in:
2024-10-15 19:32:26 -04:00
parent 59b7e3dada
commit 4a0bac5b87

View File

@ -354,19 +354,17 @@ def todoist_scrobble_task(todoist_task: dict, user_id: int) -> Scrobble:
task = Task.find_or_create(title) task = Task.find_or_create(title)
# is_complete = "completed" in todoist_task["todoist_event"]
is_no_longer_in_progress = (
"inprogress" not in todoist_task["todoist_label_list"]
)
if is_no_longer_in_progress:
scrobble = todoist_scrobble_task_finish(todoist_task, user_id)
in_progress_scrobble = Scrobble.objects.filter( in_progress_scrobble = Scrobble.objects.filter(
in_progress=True, in_progress=True,
log__todoist_id=todoist_task.get("todoist_id"), log__todoist_id=todoist_task.get("todoist_id"),
task=task, task=task,
).last() ).last()
if in_progress_scrobble: is_no_longer_in_progress = (
"inprogress" not in todoist_task["todoist_label_list"]
)
if in_progress_scrobble
if is_no_longer_in_progress:
scrobble = todoist_scrobble_task_finish(todoist_task, user_id)
return in_progress_scrobble return in_progress_scrobble
# TODO Should use updated_at from TOdoist, but parsing isn't working # TODO Should use updated_at from TOdoist, but parsing isn't working