-
Notifications
You must be signed in to change notification settings - Fork 9
Test #686
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+60
−4
Merged
Test #686
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
f99277e
feat(measurement-jobs): free-tier card gate (setup mode) + instant ba…
sweetmantech 158a1d4
Merge remote-tracking branch 'origin/main' into test
sweetmantech 5fa5e3a
fix(songstats-backfill): backoff on 429 + defer instead of churn (cha…
sweetmantech 1e9deac
Merge remote-tracking branch 'origin/main' into test
sweetmantech 5f45946
refactor(songstats): remove local quota ledger + budget gate (chat#17…
sweetmantech 5472795
Merge remote-tracking branch 'origin/main' into test
sweetmantech f24d4c7
feat: POST /api/catalogs (create + materialize from valuation snapsho…
sweetmantech ace0b01
Merge remote-tracking branch 'origin/main' into test
sweetmantech a520a1d
fix: LEFT-join artists in catalog-songs read (materialized tracks wer…
sweetmantech 76b5739
Merge remote-tracking branch 'origin/main' into test
sweetmantech 709ea0c
feat: add X (Twitter) + LinkedIn to the Composio connector whitelist …
sweetmantech 8a3c3cb
Merge remote-tracking branch 'origin/main' into test
sweetmantech 66cc2fe
chore: remove unused ALLOWED_ARTIST_CONNECTORS from api (chat#1793) (…
sweetmantech 79c22da
Merge remote-tracking branch 'origin/main' into test
sweetmantech 6fc10cc
fix: enrich valuation-captured songs (artists + notes) so they render…
sweetmantech File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,6 +4,10 @@ import { upsertSongs } from "@/lib/supabase/songs/upsertSongs"; | |||||||||
| import { upsertSongIdentifiers } from "@/lib/supabase/song_identifiers/upsertSongIdentifiers"; | ||||||||||
| import { SpotifyAlbumPlayCounts } from "@/lib/apify/spotify/fetchSpotifyAlbumPlayCounts"; | ||||||||||
| import { SpotifyRateLimitError } from "@/lib/spotify/SpotifyRateLimitError"; | ||||||||||
| import { getSpotifyArtists } from "@/lib/songs/getSpotifyArtists"; | ||||||||||
| import { linkSongsToArtists } from "@/lib/songs/linkSongsToArtists"; | ||||||||||
| import { queueRedisSongs } from "@/lib/songs/queueRedisSongs"; | ||||||||||
| import { SongWithSpotify } from "@/lib/songs/getSongsByIsrc"; | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * Self-mapping bootstrap (chat#1794): resolve ISRCs for actor tracks that have | ||||||||||
|
|
@@ -49,20 +53,35 @@ export async function mapUnmappedAlbumTracks( | |||||||||
| name: track.name, | ||||||||||
| albumId: context.albumId, | ||||||||||
| albumName: context.albumName, | ||||||||||
| spotifyArtists: getSpotifyArtists(track.artists ?? []), | ||||||||||
| }, | ||||||||||
| ]; | ||||||||||
| }); | ||||||||||
| if (resolved.length === 0) return new Map(); | ||||||||||
|
|
||||||||||
| // Dedupe by ISRC: reissues put the same recording on several albums in one | ||||||||||
| // batch, and upsertSongs' DO UPDATE cannot affect the same row twice. | ||||||||||
| const songsByIsrc = new Map( | ||||||||||
| // batch, and upsertSongs' DO UPDATE cannot affect the same row twice. Carry | ||||||||||
| // the Spotify artists through for enrichment. | ||||||||||
| const songsByIsrc = new Map<string, SongWithSpotify>( | ||||||||||
| resolved.map(r => [ | ||||||||||
| r.isrc, | ||||||||||
| { isrc: r.isrc, name: r.name ?? null, album: r.albumName ?? null }, | ||||||||||
| { | ||||||||||
| isrc: r.isrc, | ||||||||||
| name: r.name ?? null, | ||||||||||
| album: r.albumName ?? null, | ||||||||||
| spotifyArtists: r.spotifyArtists, | ||||||||||
| }, | ||||||||||
| ]), | ||||||||||
| ); | ||||||||||
| await upsertSongs([...songsByIsrc.values()]); | ||||||||||
| const songs = [...songsByIsrc.values()]; | ||||||||||
|
|
||||||||||
| await upsertSongs( | ||||||||||
| songs.map(song => { | ||||||||||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||||||||||
| const { spotifyArtists, ...record } = song; | ||||||||||
| return record; | ||||||||||
| }), | ||||||||||
| ); | ||||||||||
| await upsertSongIdentifiers( | ||||||||||
| resolved.flatMap(r => [ | ||||||||||
| { song: r.isrc, platform: "spotify", identifier_type: "track_id", value: r.trackId }, | ||||||||||
|
|
@@ -72,6 +91,13 @@ export async function mapUnmappedAlbumTracks( | |||||||||
| ]), | ||||||||||
| ); | ||||||||||
|
|
||||||||||
| // Root cause (chat#1801): give captured songs the same enrichment as the | ||||||||||
| // manual/CSV flow — link artists (auto-creating the artist account) and | ||||||||||
| // queue note generation — so valuation tracks aren't "missing info" and | ||||||||||
| // render in the catalog view rather than being filtered out. | ||||||||||
| await linkSongsToArtists(songs); | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: Artist-link enrichment failure now aborts mapping output. This causes successful identifier upserts to be treated as failed bootstrap and retried unnecessarily. Prompt for AI agents
Suggested change
|
||||||||||
| await queueRedisSongs(songs); | ||||||||||
|
|
||||||||||
| return new Map(resolved.map(r => [r.trackId, r.isrc])); | ||||||||||
| } catch (error) { | ||||||||||
| if (error instanceof SpotifyRateLimitError) throw error; | ||||||||||
|
|
||||||||||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: Custom agent: Enforce Clear Code Style and Maintainability Practices
File exceeds the 100-line limit (107 lines). Split secondary concerns (artist linking and Redis queuing) into a separate module or helper to bring this file back under 100 lines and preserve single responsibility.
Prompt for AI agents