gg
This commit is contained in:
@@ -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,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user