Skip to content

feat(etl): port social triggers — handle_follow/save/repost (parity 1B)#239

Open
raymondjacobson wants to merge 1 commit intoetl/parity-1a-aggregate-tablesfrom
etl/parity-1b-social-triggers
Open

feat(etl): port social triggers — handle_follow/save/repost (parity 1B)#239
raymondjacobson wants to merge 1 commit intoetl/parity-1a-aggregate-tablesfrom
etl/parity-1b-social-triggers

Conversation

@raymondjacobson
Copy link
Copy Markdown
Contributor

Summary

Stack 1B of the trigger-port plan. Migration 0018 adds:

  • `aggregate_user.score` column (used by trigger shadowban check; default 0 = not shadowbanned, matching apps' bootstrap state).
  • `handle_follow` — maintains `aggregate_user.{follower_count,following_count}`, inserts milestone rows + follower-count and follow notifications.
  • `handle_save` — maintains `aggregate_track.save_count` / `aggregate_playlist.save_count` / `aggregate_user.track_save_count`, plus milestone, save, save-of-repost, and remix-cosign notifications.
  • `handle_repost` — maintains repost counts on `aggregate_track` / `aggregate_playlist` / `aggregate_user`, plus milestone, repost, repost-of-repost, and remix-cosign notifications.

Stubs

`handle_save` references two tables that don't exist in go-openaudio yet:

  • `usdc_purchases` (Solana-side; intentionally out of scope per the parity plan)
  • `playlist_tracks` (Stack 2A)

Both `is_purchased` and `is_containing_album_purchased` are stubbed to `false`. Without Solana indexing nothing is purchased, so this is the correct value for the current environment. When Stack 2A lands, the `playlist_tracks` JOIN can be re-introduced (it only matters once `usdc_purchases` exists, which is a separate Solana effort).

Stack context

Stacked on #238 (1A — aggregate tables).

  • 1A — aggregate + milestone tables (feat(etl): add aggregate and milestone tables (parity 1A) #238)
  • 1B (this PR) — social triggers (handle_follow/save/repost)
  • 1C — content triggers (handle_track/playlist/play)
  • 1D — wire notification creation into triggers
  • 1E — secondary triggers (handle_comment/event/share/supporter_rank_ups)

Test plan

Six DB-backed tests in social_triggers_test.go:

  • `TestTrigger_HandleFollow_TicksAggregateCounts` — follower/following counts increment
  • `TestTrigger_HandleFollow_CreatesNotification` — `type='follow'` row appears in `notification`
  • `TestTrigger_HandleSave_TicksTrackSaveCount` — track + user save counts increment
  • `TestTrigger_HandleSave_CreatesNotification` — `type='save'` notification fires
  • `TestTrigger_HandleRepost_TicksRepostCounts` — track + user repost counts increment
  • `TestTrigger_HandleUnfollow_DecrementsCounts` — counts go back down
  • Existing entity_manager test suite still passes (no regressions from added triggers)
  • `go build ./...` clean

🤖 Generated with Claude Code

Stack 1B of the trigger-port plan. Adds migration 0018 with:

- aggregate_user.score column (used by trigger shadowban check; default 0
  means everyone passes, matching apps' bootstrap state before scores are
  computed).
- handle_follow: maintains aggregate_user.{follower_count,following_count},
  inserts milestone rows + follower-count and follow notifications.
- handle_save: maintains aggregate_track.save_count or
  aggregate_playlist.save_count, aggregate_user.track_save_count, plus
  milestone, save, save-of-repost, and remix-cosign notifications.
- handle_repost: maintains repost counts on aggregate_track /
  aggregate_playlist / aggregate_user, plus milestone, repost,
  repost-of-repost, and remix-cosign notifications.

The handle_save port stubs is_purchased / is_containing_album_purchased to
false. The original references usdc_purchases (Solana-side, intentionally
out of scope for go-openaudio) and playlist_tracks (Stack 2A); without
Solana indexing nothing is purchased so false is the correct value.

Six DB-backed tests verify trigger fire-and-effect for follow / save /
repost and unfollow decrement.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant