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 prisma: PrismaService,
|
||||||
private readonly gateway: NowPlayingGateway,
|
private readonly gateway: NowPlayingGateway,
|
||||||
private readonly recordSync: RecordStationSyncService,
|
private readonly recordSync: RecordStationSyncService,
|
||||||
) {}
|
) {
|
||||||
|
this.logger.log('NowPlayingService initialized');
|
||||||
|
}
|
||||||
|
|
||||||
@Interval(30000)
|
@Interval(30000)
|
||||||
async pollRecordNowPlaying() {
|
async pollRecordNowPlaying() {
|
||||||
|
this.logger.debug('Polling Record now playing...');
|
||||||
try {
|
try {
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
'https://www.radiorecord.ru/api/stations/now/',
|
'https://www.radiorecord.ru/api/stations/now/',
|
||||||
@@ -44,6 +47,7 @@ export class NowPlayingService {
|
|||||||
result: RecordNowPlayingItem[];
|
result: RecordNowPlayingItem[];
|
||||||
};
|
};
|
||||||
const nowPlaying = data.result ?? [];
|
const nowPlaying = data.result ?? [];
|
||||||
|
let updatedCount = 0;
|
||||||
|
|
||||||
for (const np of nowPlaying) {
|
for (const np of nowPlaying) {
|
||||||
const stationId =
|
const stationId =
|
||||||
@@ -73,7 +77,12 @@ export class NowPlayingService {
|
|||||||
coverUrl,
|
coverUrl,
|
||||||
updatedAt: updated.updatedAt,
|
updatedAt: updated.updatedAt,
|
||||||
});
|
});
|
||||||
|
updatedCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.logger.log(
|
||||||
|
`Polled ${nowPlaying.length} entries, updated ${updatedCount} stations`,
|
||||||
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logger.error(`Failed to poll now playing: ${error.message}`);
|
this.logger.error(`Failed to poll now playing: ${error.message}`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user