const path = require('path'); const {backupDatabase} = require('../src/utils/backup-database'); const {importBokanteComments} = require('../src/utils/import-bokante-comments'); const {backfillBokanteMirror} = require('../src/utils/backfill-bokante-mirrors'); module.exports = { myJob: { task: ({ strapi }) => { const dbPath = path.join(__dirname, '..', process.env.DATABASE_FILENAME || '.tmp/data.db'); const backupsDir = path.join(__dirname, '..', 'backups'); const backupPath = backupDatabase({dbPath, backupsDir}); if (backupPath) { strapi.log.info(`Sauvegarde de la base effectuée : ${backupPath}`); } else { strapi.log.warn(`Sauvegarde de la base ignorée : fichier introuvable (${dbPath})`); } }, options: { rule: '0 0 * * SUN', tz: 'Indian/Reunion', }, }, importBokanteComments: { task: async ({ strapi }) => { if (!process.env.BOKANTE_ACCESS_TOKEN) { return; } const {imported} = await importBokanteComments({strapi}); if (imported > 0) { strapi.log.info(`Import bokante : ${imported} commentaire(s) importé(s).`); } }, options: { rule: '*/20 * * * *', tz: 'Indian/Reunion', }, }, backfillBokanteMirror: { task: async ({ strapi }) => { if (!process.env.BOKANTE_ACCESS_TOKEN) { return; } const {backfilled, slug} = await backfillBokanteMirror({strapi}); if (backfilled) { strapi.log.info(`Backfill bokante : parole "${slug}" publiée.`); } }, options: { rule: process.env.BOKANTE_BACKFILL_CRON || '0 * * * *', tz: 'Indian/Reunion', }, }, };