[tasks] We only care about in-progress for scrobbling
This commit is contained in:
@ -353,6 +353,14 @@ def todoist_scrobble_task(todoist_task: dict, user_id: int) -> Scrobble:
|
|||||||
title = " ".join([prefix.capitalize(), suffix.capitalize()])
|
title = " ".join([prefix.capitalize(), suffix.capitalize()])
|
||||||
|
|
||||||
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"),
|
||||||
@ -361,9 +369,6 @@ def todoist_scrobble_task(todoist_task: dict, user_id: int) -> Scrobble:
|
|||||||
if in_progress_scrobble:
|
if in_progress_scrobble:
|
||||||
return 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
|
# TODO Should use updated_at from TOdoist, but parsing isn't working
|
||||||
scrobble_dict = {
|
scrobble_dict = {
|
||||||
"user_id": user_id,
|
"user_id": user_id,
|
||||||
|
|||||||
@ -60,10 +60,7 @@ def todoist_webhook(request):
|
|||||||
if not user_id:
|
if not user_id:
|
||||||
user_id = 1
|
user_id = 1
|
||||||
|
|
||||||
if "completed" in todoist_task["todoist_event"]:
|
scrobble = todoist_scrobble_task(todoist_task, user_id)
|
||||||
scrobble = todoist_scrobble_task_finish(todoist_task, user_id)
|
|
||||||
else:
|
|
||||||
scrobble = todoist_scrobble_task(todoist_task, user_id)
|
|
||||||
|
|
||||||
if not scrobble:
|
if not scrobble:
|
||||||
return Response(
|
return Response(
|
||||||
|
|||||||
Reference in New Issue
Block a user