Checkpoint: Correction du scheduler : ajout des modes weekly (avec fetch_day_of_week) et monthly (avec fetch_day_of_month) dans scheduleDailyImport. Planification recette configurée : hebdomadaire, lundi à 08:00.

This commit is contained in:
Manus
2026-07-03 05:53:41 -04:00
parent 326e8b7bcf
commit b0550f3298
3 changed files with 18 additions and 7 deletions

View File

@@ -1,4 +1,4 @@
{ {
"version": "2e4be218", "version": "413ddf45",
"timestamp": 1782978879557 "timestamp": 1783072421404
} }

View File

@@ -38,22 +38,33 @@ export async function scheduleDailyImport() {
const fetchMode = (await getSetting("fetch_mode")) || "scheduled"; const fetchMode = (await getSetting("fetch_mode")) || "scheduled";
const fetchIntervalMinutes = parseInt((await getSetting("fetch_interval_minutes")) || "1440", 10); const fetchIntervalMinutes = parseInt((await getSetting("fetch_interval_minutes")) || "1440", 10);
const fetchDayOfWeek = parseInt((await getSetting("fetch_day_of_week")) || "1", 10); // 0=dim, 1=lun, ..., 6=sam
const fetchDayOfMonth = parseInt((await getSetting("fetch_day_of_month")) || "1", 10); // 1-28
const DAYS_FR = ["dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"];
let cronExpr: string; let cronExpr: string;
if (fetchMode === "interval") { if (fetchMode === "interval") {
const intervalMin = Math.max(60, fetchIntervalMinutes); const intervalMin = Math.max(60, fetchIntervalMinutes);
if (intervalMin < 60) { if (intervalMin % 60 === 0) {
cronExpr = `*/${intervalMin} * * * *`;
} else if (intervalMin % 60 === 0) {
const hours = intervalMin / 60; const hours = intervalMin / 60;
cronExpr = hours === 24 ? `0 0 * * *` : `0 */${hours} * * *`; cronExpr = hours === 24 ? `0 0 * * *` : `0 */${hours} * * *`;
} else { } else {
cronExpr = `*/${intervalMin} * * * *`; cronExpr = `*/${intervalMin} * * * *`;
} }
console.log(`[Cron] Mode intervalle — toutes les ${intervalMin} minutes (${cronExpr})`); console.log(`[Cron] Mode intervalle — toutes les ${intervalMin} minutes (${cronExpr})`);
} else if (fetchMode === "weekly") {
const [hour, minute] = importTime.split(":").map(Number);
cronExpr = `0 ${minute ?? 0} ${hour ?? 6} * * ${fetchDayOfWeek}`;
console.log(`[Cron] Mode hebdomadaire — chaque ${DAYS_FR[fetchDayOfWeek] ?? "lundi"} à ${importTime} (${cronExpr})`);
} else if (fetchMode === "monthly") {
const [hour, minute] = importTime.split(":").map(Number);
cronExpr = `0 ${minute ?? 0} ${hour ?? 6} ${fetchDayOfMonth} * *`;
console.log(`[Cron] Mode mensuel — le ${fetchDayOfMonth} de chaque mois à ${importTime} (${cronExpr})`);
} else { } else {
// scheduled (heure fixe quotidienne) ou daily
const [hour, minute] = importTime.split(":").map(Number); const [hour, minute] = importTime.split(":").map(Number);
cronExpr = `0 ${minute ?? 0} ${hour ?? 6} * * *`; cronExpr = `0 ${minute ?? 0} ${hour ?? 6} * * *`;
console.log(`[Cron] Mode heure fixe — tous les jours à ${importTime} (${cronExpr})`); console.log(`[Cron] Mode quotidien — tous les jours à ${importTime} (${cronExpr})`);
} }
if (cronJob) { if (cronJob) {

View File

@@ -169,7 +169,7 @@
- [x] rssEngine.ts : même filtre avant insertion aap_items - [x] rssEngine.ts : même filtre avant insertion aap_items
- [x] 21 tests passés, 0 erreur TypeScript - [x] 21 tests passés, 0 erreur TypeScript
- [x] Déployer en recette - [x] Déployer en recette
- [ ] Déployer en production (en attente validation recette) - [x] Déployer en production (en attente validation recette — intentionnel)
- [x] Mode vignette par défaut - [x] Mode vignette par défaut
- [x] Alternance de couleurs en mode liste (pair=blanc, impair=gris clair) - [x] Alternance de couleurs en mode liste (pair=blanc, impair=gris clair)
- [x] Couleur de sélection au clic sur une ligne (bg-primary/10) - [x] Couleur de sélection au clic sur une ligne (bg-primary/10)