Skip to content

feat(etl): track/album price history tables and writes (parity 2B)#243

Open
raymondjacobson wants to merge 1 commit intoetl/parity-2a-playlist-tracksfrom
etl/parity-2b-price-history
Open

feat(etl): track/album price history tables and writes (parity 2B)#243
raymondjacobson wants to merge 1 commit intoetl/parity-2a-playlist-tracksfrom
etl/parity-2b-price-history

Conversation

@raymondjacobson
Copy link
Copy Markdown
Contributor

Summary

Stack 2B. Adds the gating-price audit trail tables and wires writes into entity_manager handlers.

Migration 0022:

  • `usdc_purchase_access_type` enum (`stream`, `download`).
  • `track_price_history` (track_id, splits, total_price_cents, blocknumber, block_timestamp, access). PK `(track_id, block_timestamp)`.
  • `album_price_history` (playlist_id, splits, total_price_cents, blocknumber, block_timestamp). PK `(playlist_id, block_timestamp)`.

Combined from apps#0017_track_price_history, #0051_usdc_purchase_access, #0058_album_price_history.

price_history.go provides `updateTrackPriceHistory` + `updateAlbumPriceHistory` mirroring apps' Python helpers:

  • `access = 'stream'` if `is_stream_gated`, else `'download'` if `is_download_gated`.
  • Skip insert when latest row matches new `(price, splits, access)` — same dedupe as apps' `equals()` check.
  • Wired into track_create / track_update / playlist_create / playlist_update.

Stack context

Stacked on #242 (2A — playlist_tracks).

Test plan

  • `TestTrackCreate_WritesTrackPriceHistory` — gated track create writes 199c row with access=stream.
  • `TestTrackCreate_NoPriceHistoryForFreeTrack` — non-gated track writes nothing.
  • `TestPlaylistCreate_WritesAlbumPriceHistory` — gated album create writes 499c row.
  • `go build ./...` clean.

🤖 Generated with Claude Code

Stack 2B. Adds the gating-price audit trail tables apps maintains and
wires writes into entity_manager handlers.

Migration 0022:
- usdc_purchase_access_type enum ('stream', 'download').
- track_price_history (track_id, splits, total_price_cents, blocknumber,
  block_timestamp, access). PK (track_id, block_timestamp).
- album_price_history (playlist_id, splits, total_price_cents, blocknumber,
  block_timestamp). PK (playlist_id, block_timestamp).

Combined from apps#0017_track_price_history, #0051_usdc_purchase_access,
and #0058_album_price_history.

price_history.go provides updateTrackPriceHistory + updateAlbumPriceHistory
mirroring apps' Python helpers in track.py / playlist.py:
- access = 'stream' if is_stream_gated, else 'download' if is_download_gated.
- Skip insert when latest row matches new (price, splits, access).
- Wire into track_create / track_update / playlist_create / playlist_update.

Three DB-backed tests cover gated track writes a row, free track does not,
gated playlist writes an album_price_history row.

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