[tasks] Fix emacs not updating or completing

This commit is contained in:
2025-10-29 17:12:48 -04:00
parent bdfbd3e5c0
commit cd60ac6387
4 changed files with 36 additions and 16 deletions

View File

@ -92,7 +92,7 @@ fetching and simple saving.
:LOGBOOK: :LOGBOOK:
CLOCK: [2025-07-09 Wed 09:55]--[2025-07-09 Wed 10:15] => 0:20 CLOCK: [2025-07-09 Wed 09:55]--[2025-07-09 Wed 10:15] => 0:20
:END: :END:
* Backlog [1/27] * Backlog [1/26]
** TODO [#C] Create small utility to clean up tracks scrobbled with wonky playback times :vrobbler:personal:bug:music:scrobbles: ** TODO [#C] Create small utility to clean up tracks scrobbled with wonky playback times :vrobbler:personal:bug:music:scrobbles:
** TODO [#C] Move to using more robust mopidy-webhooks pacakge form pypi :utility:improvement: ** TODO [#C] Move to using more robust mopidy-webhooks pacakge form pypi :utility:improvement:
:PROPERTIES: :PROPERTIES:
@ -480,6 +480,17 @@ https://life.lab.unbl.ink/scrobble/e39779c8-62a5-46a6-bdef-fb7662810dc6/start/
This may have already been resolved ... need to just confirm it. This may have already been resolved ... need to just confirm it.
** TODO [#A] Find page numbers for comic books from ComicVine :vrobbler:feature:books:personal:project: ** TODO [#A] Find page numbers for comic books from ComicVine :vrobbler:feature:books:personal:project:
** DONE [#A] Emacs tasks are duplicating rather than updating :vrobbler:bug:tasks:emacs:personal:project:
:PROPERTIES:
:ID: e93efc25-7ce9-8ef2-662e-0a19dd0b29c9
:END:
- Note taken on [2025-10-29 Wed 16:38]
Turns out I was misusing `orgmode` for the source of tasks when it shoulda been `Org-mode`
A good lesson in using constants for things.
* Version 33.0 [3/3] * Version 33.0 [3/3]
** DONE [#A] Fix bug where scrobble is_stale only uses seconds not total_seconds :vrobbler:bug:scrobbles:personal:project: ** DONE [#A] Fix bug where scrobble is_stale only uses seconds not total_seconds :vrobbler:bug:scrobbles:personal:project:
:PROPERTIES: :PROPERTIES:

View File

@ -796,7 +796,6 @@ def emacs_scrobble_task(
user_id=user_id, user_id=user_id,
in_progress=True, in_progress=True,
log__orgmode_id=orgmode_id, log__orgmode_id=orgmode_id,
log__source="orgmode",
task=task, task=task,
).last() ).last()

View File

@ -949,8 +949,11 @@ class ScrobbleDetailView(DetailView):
log = self.object.log or {} log = self.object.log or {}
initial_notes = log.get("notes", []) initial_notes = log.get("notes", [])
if isinstance(initial_notes, list): if isinstance(initial_notes, list) and isinstance(initial_notes[0], dict):
notes_str = note_list_to_str(notes)
else:
notes_str = "\n".join(initial_notes) notes_str = "\n".join(initial_notes)
notes_str_fixed = notes_str.encode("utf-8").decode( notes_str_fixed = notes_str.encode("utf-8").decode(
"unicode_escape" "unicode_escape"
) )

View File

@ -39,15 +39,22 @@ class TaskLogData(BaseLogData):
def notes_as_str(self) -> str: def notes_as_str(self) -> str:
"""Return formatted notes with line breaks and no keys""" """Return formatted notes with line breaks and no keys"""
note_block = "" labels_str = ""
if isinstance(self.notes, list): if self.labels:
note_block = "</br>".join(self.notes) labels_str = ", ".join(self.labels)
# DEPRECATED ... we don't store notes in dicts anymore lines = []
if isinstance(self.notes, dict): if self.notes:
for id, content in self.notes.items(): for note in self.notes:
note_block += content + "</br>" if isinstance(note, dict):
return note_block timestamp, note_text = next(iter(note.items()))
# Flatten newlines and clean whitespace
note_text = " ".join(note_text.strip().split())
lines.append(f"{timestamp}: {note_text} [{labels_str}]")
if isinstance(note, str):
lines.append(note)
return "\n".join(lines)
class Task(LongPlayScrobblableMixin): class Task(LongPlayScrobblableMixin):
@ -82,7 +89,7 @@ class Task(LongPlayScrobblableMixin):
def subtitle_for_user(self, user_id): def subtitle_for_user(self, user_id):
scrobble = self.scrobbles(user_id).first() scrobble = self.scrobbles(user_id).first()
return scrobble.logdata.title or "" return scrobble.logdata.title or scrobble.log.get("title")
@classmethod @classmethod
def find_or_create(cls, title: str) -> "Task": def find_or_create(cls, title: str) -> "Task":