Populate flowsheet.dj_name on marker rows and surface it in v2#953
Merged
Conversation
show_start/show_end/dj_join/dj_leave rows were inserted without a dj_name column value, and the v2 serializer was regex-parsing the human-readable message field to recover it. The regex silently failed for upstream inserts, so /flowsheet returned dj_name: "" on every marker entry — visible in the iOS app and dj-site as bare "Signed on/off" rows with no DJ attribution. - startShow / endShow / createJoinNotification / createLeaveNotification now persist dj_name on insert, matching the precedence used by resolveDjNameForShow and the search service's DJ_NAME_EXPR. - transformToV2 reads entry.dj_name directly for the four marker types and derives timestamp from add_time instead of parsing the message string. The message format is unchanged for v1 consumers. - flowsheet-dj-name-backfill widens its filter to cover the four marker entry types alongside track. Guest dj_join/dj_leave rows backfill against shows.primary_dj_id (best-effort historically; new rows are exact).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #952.
Problem
The v2
/flowsheetendpoint returneddj_name: ""on everyshow_start/show_endentry (and the same code path applied todj_join/dj_leave). Verified live: 19/19 markers across a 48-hour window. iOS rendered the bare "Signed on/off" fallback; dj-site did the same.Two-part root cause in
apps/backend/services/flowsheet.service.ts:startShow,endShow,createJoinNotification,createLeaveNotificationinserted flowsheet rows without setting thedj_namecolumn. TheaddEntrytrack path already did this (closed Populate flowsheet.dj_name on insert (step 5b.2) #476), but the marker paths were missed.transformToV2regex-parseddj_nameout of the human-readablemessagefield instead of reading the column. The regex silently failed and returned''.Change
dj_nameusing the sameauth_user.djName || auth_user.nameprecedence as the existing track path andresolveDjNameForShow. Message strings unchanged for v1 consumers.transformToV2readsentry.dj_namedirectly for marker types;timestamp(show_start/show_end only) is derived fromentry.add_timeviatoLocaleString('en-US', { timeZone: 'America/New_York' })— same format the old regex was extracting from the message.jobs/flowsheet-dj-name-backfillwidens its filter fromentry_type = 'track'to also cover the four marker types. Joins throughshows.primary_dj_id— best-effort for historical guestdj_join/dj_leaverows (those will carry the primary DJ's name); new rows from the live insert path are exact.TDD
Five steps, each Red → Green:
startShow/endShowpersistence —tests/unit/services/flowsheet.startShow.test.ts,flowsheet.endShow.test.ts(new).dj_join/dj_leavepersistence —tests/unit/services/flowsheet.joinLeaveNotifications.test.ts(new).transformToV2reads from column — rewrote the marker describe blocks inflowsheet.service.test.tsto assert column read and ignore message content.tests/unit/jobs/flowsheet-dj-name-backfill/job.test.tsto assert the newentry_type IN (...)filter.CLAUDE.mdentry, file-header comments inflowsheet.service.ts(L755-761) andjob.ts.Final: 67/67 tests green on the modified suites. (Pre-existing failures in
library.service.test.ts,flowsheet.controller.test.ts,internal.route.test.tsare unrelated — LRUCache import + network socket binding; they fail onmaintoo.)Verification plan
npm run test:unit(all modified suites green; pre-existing failures unchanged).npm run test:integration(no regression).docker run --rm --env-file .env <flowsheet-dj-name-backfill image>. ConfirmverifyCompletereports 0 missing.curl -s "https://staging-api.wxyc.org/flowsheet?shows_limit=10" | jq '.entries[] | select(.entry_type | startswith("show_") or startswith("dj_")) | {entry_type, dj_name, timestamp}'— every marker has a populateddj_name."<DJ> signed on/off"renders.Out of scope
dj_join/dj_leaverows (acknowledged limitation; follow-up if needed).shows.legacy_dj_nameETL gap) and flowsheet-etl: post-import dj_name UPDATE crashes on large legacy_entry_id batches (400+ param ANY clause) #939 (large-batchANY((...))crash) — separate bugs. This fix is robust to both: missing legacy data insertsdj_name = nulland the next backfill picks it up.