Browse Source

[tasks] Remove in-progress tag to stop

Colin Powell 8 tháng trước cách đây
mục cha
commit
8fb2fac47f
2 tập tin đã thay đổi với 7 bổ sung3 xóa
  1. 6 1
      vrobbler/apps/scrobbles/scrobblers.py
  2. 1 2
      vrobbler/apps/tasks/webhooks.py

+ 6 - 1
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,

+ 1 - 2
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: