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