Now-playing publisher and worker task (phase 4, step 3)
CI / validate-monitoring (push) Successful in 8s
CI / lint (push) Successful in 11s
CI / federation-interop (push) Successful in 1m7s
CI / test (push) Successful in 3m15s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 6s

publishing/now_playing.py: a periodic scan (federation.now_playing,
every 30s) that pushes a throttled Update(Person) for the profile
field (5 minutes) and, for users opted into posts, publishes a Note
after a track's been playing 30+ seconds (throttled to 30 minutes),
deleting the previous now-playing post once the new one is confirmed
published - not before, so a failed publish never leaves a user with
none showing. Reuses publishing.publish()/delete_post() unchanged;
now_playing is just another post kind.

Fixed a real bug before it ever ran against Postgres: the key
(artist/track/started_at) was going straight into federation_posts.key
(VARCHAR(64)), which routinely overflows for real track and artist
names. Hashed instead - it's an idempotency token, not something
anyone needs to read.

New metric scrobbler_federation_profile_updates_total{result}; posts
already get scrobbler_federation_posts_total{kind="now_playing",...}
for free from the existing publish() instrumentation.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
This commit is contained in:
mattandClaude Sonnet 5 committed 2026-09-26 17:13:10 +01:00
1 parent 9ab8bd8e03
commit ba30d5cb15
5 files changed
+382 -5

No files matched your search

+7 -1
View File
@@ -53,7 +53,7 @@ followers = Gauge(
)
posts_total = Counter(
"scrobbler_federation_posts_total",
"Posts published: weekly summaries and milestones",
"Posts published: weekly summaries, milestones and now-playing",
["kind", "visibility"],
)
post_deletions_total = Counter(
@@ -71,3 +71,9 @@ weekly_total = Counter(
"Weekly summary checks, by result: disabled, skipped_empty, already_posted or posted",
["result"],
)
profile_updates_total = Counter(
"scrobbler_federation_profile_updates_total",
"Now-playing Update(Person) pushes: sent, or throttled (still within the 5-minute "
"window since the last one)",
["result"],
)