mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-02-13 10:52:53 +00:00
feat: check status of repository
This commit is contained in:
@@ -93,7 +93,10 @@ export default class Repository {
|
||||
* Check the status of the repository
|
||||
*/
|
||||
check() {
|
||||
if (this._model.options.expirationMode !== "never") {
|
||||
if (
|
||||
this._model.options.expirationMode !== "never" &&
|
||||
this._model.status == "ready"
|
||||
) {
|
||||
if (this._model.options.expirationDate <= new Date()) {
|
||||
this.expire();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
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 conference
|
||||
// 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) => {
|
||||
@@ -15,3 +17,15 @@ export function conferenceStatusCheck() {
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
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();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import * as passport from "passport";
|
||||
import * as connection from "./routes/connection";
|
||||
import router from "./routes";
|
||||
import AnonymizedRepositoryModel from "./database/anonymizedRepositories/anonymizedRepositories.model";
|
||||
import { conferenceStatusCheck } from "./schedule";
|
||||
import { conferenceStatusCheck, repositoryStatusCheck } from "./schedule";
|
||||
|
||||
function indexResponse(req: express.Request, res: express.Response) {
|
||||
if (
|
||||
@@ -100,6 +100,7 @@ export default async function start() {
|
||||
|
||||
// start schedules
|
||||
conferenceStatusCheck();
|
||||
repositoryStatusCheck();
|
||||
|
||||
await db.connect();
|
||||
app.listen(config.PORT);
|
||||
|
||||
Reference in New Issue
Block a user