[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:
CLOCK: [2025-07-09 Wed 09:55]--[2025-07-09 Wed 10:15] => 0:20
: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] Move to using more robust mopidy-webhooks pacakge form pypi :utility:improvement:
: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.
** 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]
** DONE [#A] Fix bug where scrobble is_stale only uses seconds not total_seconds :vrobbler:bug:scrobbles:personal:project:
:PROPERTIES:

View File

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

View File

@ -949,12 +949,15 @@ class ScrobbleDetailView(DetailView):
log = self.object.log or {}
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_fixed = notes_str.encode("utf-8").decode(
"unicode_escape"
)
log["notes"] = notes_str_fixed
notes_str_fixed = notes_str.encode("utf-8").decode(
"unicode_escape"
)
log["notes"] = notes_str_fixed
return FormClass(initial=log)

View File

@ -39,15 +39,22 @@ class TaskLogData(BaseLogData):
def notes_as_str(self) -> str:
"""Return formatted notes with line breaks and no keys"""
note_block = ""
if isinstance(self.notes, list):
note_block = "</br>".join(self.notes)
labels_str = ""
if self.labels:
labels_str = ", ".join(self.labels)
# DEPRECATED ... we don't store notes in dicts anymore
if isinstance(self.notes, dict):
for id, content in self.notes.items():
note_block += content + "</br>"
return note_block
lines = []
if self.notes:
for note in self.notes:
if isinstance(note, dict):
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):
@ -82,7 +89,7 @@ class Task(LongPlayScrobblableMixin):
def subtitle_for_user(self, user_id):
scrobble = self.scrobbles(user_id).first()
return scrobble.logdata.title or ""
return scrobble.logdata.title or scrobble.log.get("title")
@classmethod
def find_or_create(cls, title: str) -> "Task":