Compare commits

1 Commits

Author SHA1 Message Date
6fc6ae833b pre-main 2026-01-30 15:22:44 +03:00

View File

@@ -16,9 +16,9 @@ export class SyncService {
constructor(
private readonly prisma: PrismaService,
private readonly scraper: ScraperService,
) { }
) {}
@Cron(CronExpression.EVERY_DAY_AT_MIDNIGHT)
@Cron(CronExpression.EVERY_HOUR)
async handleDailySync() {
this.logger.log('Starting daily game synchronization job...');
for (const url of this.TARGET_URLS) {
@@ -36,7 +36,10 @@ export class SyncService {
await this.upsertGame(gameData);
}
} catch (error) {
this.logger.error(`Failed to sync URL ${url}: ${error.message}`, error.stack);
this.logger.error(
`Failed to sync URL ${url}: ${error.message}`,
error.stack,
);
}
}
@@ -63,7 +66,7 @@ export class SyncService {
releaseDateText: dateText,
isTBD: isTBD,
sourceUrl: data.sourceUrl,
}
},
});
// this.logger.debug(`Upserted game: ${data.title}`);
} catch (error) {
@@ -78,7 +81,11 @@ export class SyncService {
.replace(/(^-|-$)+/g, '');
}
private parseDate(rawDate?: string): { releaseDate: Date | null, isTBD: boolean, dateText: string | null } {
private parseDate(rawDate?: string): {
releaseDate: Date | null;
isTBD: boolean;
dateText: string | null;
} {
if (!rawDate) return { releaseDate: null, isTBD: true, dateText: 'TBD' };
// Clean string
@@ -105,7 +112,7 @@ export class SyncService {
return {
releaseDate: date,
isTBD: date === null,
dateText: clean
dateText: clean,
};
}
}