A decentralized music tracking and discovery platform built on AT Protocol 🎵 rocksky.app
spotify atproto lastfm musicbrainz scrobbling listenbrainz
97
fork

Configure Feed

Select the types of activity you want to include in your feed.

Upsert user scrobbles on conflict

Replace onConflictDoNothing with onConflictDoUpdate for songs,
albums, and artists. Use composite conflict targets (userId + id)
and set scrobbles to 1 when a conflict occurs.

+13 -3
+13 -3
apps/api/src/scripts/collections.ts
··· 348 348 uri: song.uri, 349 349 scrobbles: 1, 350 350 }) 351 - .onConflictDoNothing() 351 + .onConflictDoUpdate({ 352 + target: [schema.userTracks.userId, schema.userTracks.trackId], 353 + set: { 354 + scrobbles: 1, 355 + }, 356 + }) 352 357 .returning() 353 358 .execute(), 354 359 ctx.db ··· 430 435 scrobbles: 1, 431 436 }) 432 437 .onConflictDoUpdate({ 433 - target: schema.userArtists.uri, 438 + target: [schema.userArtists.userId, schema.userArtists.artistId], 434 439 set: { 435 440 scrobbles: 1, 436 441 }, ··· 502 507 uri: album.uri, 503 508 scrobbles: 1, 504 509 }) 505 - .onConflictDoNothing() 510 + .onConflictDoUpdate({ 511 + target: [schema.userAlbums.userId, schema.userAlbums.albumId], 512 + set: { 513 + scrobbles: 1, 514 + }, 515 + }) 506 516 .execute(), 507 517 ctx.db 508 518 .insert(schema.artistAlbums)