Przeglądaj źródła

[scrobbles] Fix double scrobbling tasks

Colin Powell 8 miesięcy temu
rodzic
commit
4a0bac5b87
1 zmienionych plików z 6 dodań i 8 usunięć
  1. 6 8
      vrobbler/apps/scrobbles/scrobblers.py

+ 6 - 8
vrobbler/apps/scrobbles/scrobblers.py

@@ -354,19 +354,17 @@ def todoist_scrobble_task(todoist_task: dict, user_id: int) -> Scrobble:
 
     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=True,
         log__todoist_id=todoist_task.get("todoist_id"),
         task=task,
     ).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
 
     # TODO Should use updated_at from TOdoist, but parsing isn't working