[task] Log when we don't find a task for notes

This commit is contained in:
2024-11-01 12:48:59 -04:00
parent d8aaf3bf55
commit 82dcad569a
2 changed files with 22 additions and 8 deletions

View File

@ -327,21 +327,31 @@ def todoist_scrobble_update_task(
log__task_id=todoist_note.get("task_id"),
).first()
if scrobble:
existing_notes = scrobble.log.get("notes", {})
existing_notes[todoist_note.get("todoist_id")] = todoist_note.get(
"content"
)
scrobble.log["notes"] = existing_notes
scrobble.save(update_fields=["log"])
if not scrobble:
logger.info(
"[todoist_scrobble_update_task] todoist note added",
"[todoist_scrobble_update_task] no task found",
extra={
"todoist_note": todoist_note,
"user_id": user_id,
"media_type": Scrobble.MediaType.TASK,
},
)
return
existing_notes = scrobble.log.get("notes", {})
existing_notes[todoist_note.get("todoist_id")] = todoist_note.get(
"content"
)
scrobble.log["notes"] = existing_notes
scrobble.save(update_fields=["log"])
logger.info(
"[todoist_scrobble_update_task] todoist note added",
extra={
"todoist_note": todoist_note,
"user_id": user_id,
"media_type": Scrobble.MediaType.TASK,
},
)
return scrobble

View File

@ -103,6 +103,10 @@ def todoist_webhook(request):
scrobble = todoist_scrobble_update_task(todoist_note, user_id)
if not scrobble:
logger.info(
"[todoist_webhook] finished with no note or task found",
extra={"scrobble_id": None},
)
return Response(
{"error": "No scrobble found to be updated"},
status=status.HTTP_304_NOT_MODIFIED,