This commit is contained in:
2026-04-19 13:23:00 +03:00
parent e4c74025e5
commit 1346924387
25 changed files with 1639 additions and 1076 deletions
+23 -12
View File
@@ -1,12 +1,16 @@
import { Injectable, Logger } from "@nestjs/common";
import { Cron } from "@nestjs/schedule";
import { FeederService } from "../modules/feeder/feeder.service";
import { TaskLockService } from "./task-lock.service";
@Injectable()
export class HistoricalResultsSyncTask {
private readonly logger = new Logger(HistoricalResultsSyncTask.name);
constructor(private readonly feederService: FeederService) {}
constructor(
private readonly feederService: FeederService,
private readonly taskLock: TaskLockService,
) {}
private shouldSkipInHistoricalMode(jobName: string): boolean {
if (process.env.FEEDER_MODE === "historical") {
@@ -25,17 +29,24 @@ export class HistoricalResultsSyncTask {
return;
}
this.logger.log(
"Starting previous-day completed match sync for football and basketball...",
);
await this.taskLock.runWithLease(
"syncPreviousDayCompletedMatches",
6 * 60 * 60 * 1000,
async () => {
this.logger.log(
"Starting previous-day completed match sync for football and basketball...",
);
try {
await this.feederService.runPreviousDayCompletedMatchesScan();
this.logger.log("Previous-day completed match sync finished");
} catch (error: any) {
this.logger.error(
`Previous-day completed match sync failed: ${error.message}`,
);
}
try {
await this.feederService.runPreviousDayCompletedMatchesScan();
this.logger.log("Previous-day completed match sync finished");
} catch (error: any) {
this.logger.error(
`Previous-day completed match sync failed: ${error.message}`,
);
}
},
this.logger,
);
}
}