mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-02-13 10:52:53 +00:00
32 lines
1.1 KiB
TypeScript
32 lines
1.1 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") {
|
|
await conference.expire();
|
|
}
|
|
}
|
|
);
|
|
});
|
|
}
|
|
|
|
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);
|
|
repo.check();
|
|
});
|
|
});
|
|
}
|