mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-02-13 02:42:45 +00:00
40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
import * as schedule from "node-schedule";
|
|
import Conference from "./Conference";
|
|
import AnonymizedRepositoryModel from "./database/anonymizedRepositories/anonymizedRepositories.model";
|
|
import ConferenceModel from "./database/conference/conferences.model";
|
|
import Repository from "./Repository";
|
|
|
|
export function conferenceStatusCheck() {
|
|
// check every 6 hours the status of the conferences
|
|
const job = schedule.scheduleJob("0 */6 * * *", async () => {
|
|
(await ConferenceModel.find({ status: { $eq: "ready" } })).forEach(
|
|
async (data) => {
|
|
const conference = new Conference(data);
|
|
if (conference.isExpired() && conference.status == "ready") {
|
|
try {
|
|
await conference.expire();
|
|
} catch (error) {
|
|
console.error(error);
|
|
}
|
|
}
|
|
}
|
|
);
|
|
});
|
|
}
|
|
|
|
export function repositoryStatusCheck() {
|
|
// check every 6 hours the status of the repositories
|
|
const job = schedule.scheduleJob("0 */6 * * *", async () => {
|
|
(
|
|
await AnonymizedRepositoryModel.find({ status: { $eq: "ready" } })
|
|
).forEach((data) => {
|
|
const repo = new Repository(data);
|
|
try {
|
|
repo.check();
|
|
} catch (error) {
|
|
console.log(`Repository ${repo.repoId} is expired`);
|
|
}
|
|
});
|
|
});
|
|
}
|