A decentralized music tracking and discovery platform built on AT Protocol 🎵

Log scrobble loading and include albumArtist match

+13 -2
+13 -2
apps/cli/src/cmd/sync.ts
··· 13 13 import schema from "schema"; 14 14 import { createId } from "@paralleldrive/cuid2"; 15 15 import _ from "lodash"; 16 - import { and, eq } from "drizzle-orm"; 16 + import { and, eq, or } from "drizzle-orm"; 17 17 import { indexBy } from "ramda"; 18 18 import fs from "node:fs"; 19 19 import os from "node:os"; ··· 415 415 const createScrobbles = async (scrobbles: Scrobbles, user: SelectUser) => { 416 416 if (!scrobbles.length) return; 417 417 418 + logger.info`Loading Scrobble Tracks ...`; 419 + 418 420 const tracks = await Promise.all( 419 421 scrobbles.map((scrobble) => 420 422 ctx.db ··· 432 434 .then(([track]) => track), 433 435 ), 434 436 ); 437 + 438 + logger.info`Loading Scrobble Albums ...`; 435 439 436 440 const albums = await Promise.all( 437 441 scrobbles.map((scrobble) => ··· 449 453 ), 450 454 ); 451 455 456 + logger.info`Loading Scrobble Artists ...`; 457 + 452 458 const artists = await Promise.all( 453 459 scrobbles.map((scrobble) => 454 460 ctx.db 455 461 .select() 456 462 .from(schema.artists) 457 - .where(and(eq(schema.artists.name, scrobble.value.artist))) 463 + .where( 464 + or( 465 + and(eq(schema.artists.name, scrobble.value.artist)), 466 + and(eq(schema.artists.name, scrobble.value.albumArtist)), 467 + ), 468 + ) 458 469 .execute() 459 470 .then(([artist]) => artist), 460 471 ),