music: backup play log from now-playing samples (origin nowplaying; 30 s or half the track, ignoring pauses and seeks); recently-played takes those rows over with its exact timestamp
All checks were successful
Deploy production / deploy (push) Successful in 1m9s
All checks were successful
Deploy production / deploy (push) Successful in 1m9s
This commit is contained in:
@@ -110,8 +110,9 @@ export const musicPlays = musicSchema.table(
|
||||
* usually when the track started. See the music.plays_deduped view. */
|
||||
playedAt: timestamptz('played_at').notNull(),
|
||||
source: text('source').notNull().default('spotify'),
|
||||
/** How the row got here: 'api' (poller), 'export' (Spotify streaming history),
|
||||
* 'import' (Last.fm and other backfills), 'manual'. */
|
||||
/** How the row got here: 'api' (poller, recently-played), 'nowplaying' (poller backup
|
||||
* log from now-playing samples, until recently-played confirms it), 'export' (Spotify
|
||||
* streaming history), 'import' (Last.fm and other backfills), 'manual'. */
|
||||
origin: text('origin').notNull().default('api'),
|
||||
/** Known for imports; null for API plays (Spotify only reports plays of 30 s or more). */
|
||||
msPlayed: integer('ms_played'),
|
||||
@@ -126,7 +127,10 @@ export const musicPlays = musicSchema.table(
|
||||
index('plays_source_played_idx').on(t.source, t.playedAt),
|
||||
index('plays_track_played_idx').on(t.trackId, t.playedAt),
|
||||
check('plays_source_check', sql`${t.source} in ('spotify', 'lastfm', 'youtube', 'local')`),
|
||||
check('plays_origin_check', sql`${t.origin} in ('api', 'export', 'import', 'manual')`)
|
||||
check(
|
||||
'plays_origin_check',
|
||||
sql`${t.origin} in ('api', 'export', 'import', 'manual', 'nowplaying')`
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user