feat(etl): port handle_user/track/playlist triggers (parity 1C)#240
Open
raymondjacobson wants to merge 1 commit intoetl/parity-1b-social-triggersfrom
Open
feat(etl): port handle_user/track/playlist triggers (parity 1C)#240raymondjacobson wants to merge 1 commit intoetl/parity-1b-social-triggersfrom
raymondjacobson wants to merge 1 commit intoetl/parity-1b-social-triggersfrom
Conversation
Stack 1C of the trigger-port plan. Migration 0019 adds:
- aggregate_user.total_track_count column (apps#0143).
- handle_user: creates aggregate_user row on user insert. Other triggers
depend on this row existing.
- handle_track: maintains aggregate_track + aggregate_user.{track_count,
total_track_count}, plus subscriber-create / remix / remix-contest
notifications. Verbatim port; fires on INSERT OR UPDATE.
- handle_playlist: maintains aggregate_playlist + aggregate_user.{playlist_count,
album_count}, plus subscriber-create and track-added-to-playlist
notifications.
handle_play deferred to a follow-up: apps' trigger fires on a `plays` table
matching apps' schema, but go-openaudio currently has only `etl_plays` (its
own staging schema). A separate PR will add the apps-shaped `plays` table
and wire the play processor before the trigger lands.
handle_playlist's `revert_blocks` lookup was stripped: go-openaudio doesn't
track reverts (chain doesn't reorg), so old_row is treated as null. On
INSERT this gives correct delta semantics. The private→public publish path
in apps fires the trigger via INSERT of a new is_current row; go-openaudio's
playlist_update.go does in-place UPDATE so this trigger won't fire on
publish today. That's tracked in Stack 4A (publish_scheduled_releases).
Six DB-backed tests cover aggregate_track init, public/unlisted track count
behavior, remix notification, playlist aggregate init, album_count
increment, and is_private suppression.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5 tasks
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.
Summary
Stack 1C of the trigger-port plan. Migration 0019 adds:
Deferred
`handle_play` — apps' trigger fires on a `plays` table matching apps' schema, but go-openaudio currently has only `etl_plays` (different schema). A follow-up PR will add the apps-shaped `plays` table and wire the play processor before the trigger lands.
Stripped (no reorg support per scoping)
`handle_playlist`'s `revert_blocks` lookup was removed (go-openaudio doesn't track reverts). With `old_row` treated as null:
The private→public publish path in apps fires the trigger via INSERT of a new `is_current` row; go-openaudio's `playlist_update.go` does in-place UPDATE so this trigger won't fire on publish today. That's tracked in Stack 4A (`publish_scheduled_releases`).
Stack context
Stacked on #239 (1B — social triggers).
Test plan
Six DB-backed tests in content_triggers_test.go:
🤖 Generated with Claude Code