diff --git a/prisma/migrations/20250602120000_add_record_station_id/migration.sql b/prisma/migrations/20250602120000_add_record_station_id/migration.sql new file mode 100644 index 0000000..9c7d9b7 --- /dev/null +++ b/prisma/migrations/20250602120000_add_record_station_id/migration.sql @@ -0,0 +1,8 @@ +-- AlterTable +ALTER TABLE "stations" ADD COLUMN "record_station_id" INTEGER; + +-- CreateIndex +CREATE UNIQUE INDEX "stations_record_station_id_key" ON "stations"("record_station_id"); + +-- CreateIndex +CREATE INDEX "stations_recordStationId_idx" ON "stations"("record_station_id"); diff --git a/src/now-playing/now-playing.service.ts b/src/now-playing/now-playing.service.ts index 376880b..63db931 100644 --- a/src/now-playing/now-playing.service.ts +++ b/src/now-playing/now-playing.service.ts @@ -26,10 +26,13 @@ export class NowPlayingService { private readonly prisma: PrismaService, private readonly gateway: NowPlayingGateway, private readonly recordSync: RecordStationSyncService, - ) {} + ) { + this.logger.log('NowPlayingService initialized'); + } @Interval(30000) async pollRecordNowPlaying() { + this.logger.debug('Polling Record now playing...'); try { const response = await fetch( 'https://www.radiorecord.ru/api/stations/now/', @@ -44,6 +47,7 @@ export class NowPlayingService { result: RecordNowPlayingItem[]; }; const nowPlaying = data.result ?? []; + let updatedCount = 0; for (const np of nowPlaying) { const stationId = @@ -73,7 +77,12 @@ export class NowPlayingService { coverUrl, updatedAt: updated.updatedAt, }); + updatedCount++; } + + this.logger.log( + `Polled ${nowPlaying.length} entries, updated ${updatedCount} stations`, + ); } catch (error) { this.logger.error(`Failed to poll now playing: ${error.message}`); }