chore: add debug logs to now-playing polling
This commit is contained in:
@@ -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");
|
||||
@@ -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}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user