Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolve #56 #61

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

resolve #56 #61

wants to merge 3 commits into from

Conversation

Kotsudes
Copy link
Contributor

Added automatic dumps of the database up to 30 days of data

@Kotsudes Kotsudes requested a review from hugoattal September 18, 2024 18:27
@Kotsudes Kotsudes linked an issue Sep 18, 2024 that may be closed by this pull request
Copy link
Contributor

@hugoattal hugoattal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quelques petits retours, mais sinon très cool 😄 !

backend/src/utils/database.ts Outdated Show resolved Hide resolved
backend/src/utils/database.ts Outdated Show resolved Hide resolved
backend/src/server.ts Outdated Show resolved Hide resolved
backend/src/server.ts Outdated Show resolved Hide resolved
@Kotsudes Kotsudes requested a review from hugoattal September 19, 2024 07:36
Copy link
Contributor

@hugoattal hugoattal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Top, c'est quasi prêt 😄 ! Il faut juste que je check que ça marche avant de déployer celui-là sinon ça risque de crasher le serveur si mongodump est pas installé 😬...

backend/src/server.ts Outdated Show resolved Hide resolved
@@ -24,4 +24,4 @@
"exclude": [
"node_modules"
]
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pourquoi y'a cette modif 🤔 ? L'eslint devrait garder les lignes vide à la fin normalement, non ?

Copy link
Contributor Author

@Kotsudes Kotsudes Sep 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'ai enfin compris. J'ai ajouté ces lignes à mon .vscode dans website

"eslint.workingDirectories": [
        {
            "mode": "auto"
        }
    ]

@Kotsudes Kotsudes requested a review from hugoattal September 24, 2024 18:55
Copy link
Contributor

@hugoattal hugoattal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Top, quelques petits retours et on est bon 😄 !



export const dumpDatabaseJob = CronJob.from({
start: false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pourquoi pas le start directement 🤔 ?

export const dumpDatabaseJob = CronJob.from({
start: false,
cronTime: "0 0 4 * * *",
onComplete: null,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Du coup y'a pas besoin de cette propriété, si ?

@@ -8,6 +8,9 @@ import APIHandler from "@/api";
import StaticHandler from "@/static";
import UploadHandler from "@/upload";
import PageHandler from "@/page";
import * as cron from "@/cronjob";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Si tu les start directement, tu peux juste import le fichier

import "@/cronjob";

const folderName = `../dumps/${ dumpDate }`;
await pfs.mkdir(folderName, { recursive: true });

const child = cs.spawn("mongodump", ["--db", "sgnw", "--out", `../dumps/${ dumpDate }`], { stdio: "inherit" });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ça serait peut être pas mal de mettre le path vers mongodump dans le .env, je suis pas sûr qu'on veuille forcément le mettre dans le Path 🤔

dirs.forEach(async (dir) => {
const [day, month, year] = dir.split("-").map(Number);
const dumpDate = new Date(year, month - 1, day);
const Difference_In_Days = Math.floor((currentDate.getTime() - dumpDate.getTime()) / (1000 * 3600 * 24));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Il y a le package date-fns qui est installé, je sais pas si c'est worth, mais jette un oeil 🤔

https://date-fns.org/v4.1.0/docs/differenceInDays

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ajouter un CRON pour dump la db
2 participants