[tasks] Finish task based on timestamp, not now
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
from datetime import datetime
|
||||
import logging
|
||||
import re
|
||||
from typing import Optional
|
||||
@ -326,7 +327,7 @@ def manual_scrobble_from_url(
|
||||
|
||||
|
||||
def todoist_scrobble_task_finish(
|
||||
todoist_task: dict, user_id: int
|
||||
todoist_task: dict, user_id: int, timestamp: datetime
|
||||
) -> Optional[Scrobble]:
|
||||
scrobble = Scrobble.objects.filter(
|
||||
user_id=user_id,
|
||||
@ -341,7 +342,7 @@ def todoist_scrobble_task_finish(
|
||||
)
|
||||
return
|
||||
|
||||
scrobble.stop(force_finish=True)
|
||||
scrobble.stop(timestamp=timestamp, force_finish=True)
|
||||
|
||||
return scrobble
|
||||
|
||||
@ -447,7 +448,7 @@ def todoist_scrobble_task(
|
||||
"todoist_id": todoist_task["todoist_id"],
|
||||
},
|
||||
)
|
||||
return todoist_scrobble_task_finish(todoist_task, user_id)
|
||||
return todoist_scrobble_task_finish(todoist_task, user_id, timestamp)
|
||||
|
||||
# Default to create new scrobble "if not in_progress_scrobble and in_progress_in_todoist"
|
||||
# TODO Should use updated_at from TOdoist, but parsing isn't working
|
||||
|
||||
Reference in New Issue
Block a user