-
Notifications
You must be signed in to change notification settings - Fork 10
/
cron.js
55 lines (51 loc) · 1.45 KB
/
cron.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const cron = require("cron")
const anonymizeConferences = require("./jobs/anonymizeConferences")
const sendSurveyEmails = require("./jobs/sendSurveyEmails")
const computeStats = require("./jobs/computeStats")
const fetchCallsStats = require("./jobs/fetchCallsStats.js")
const config = require("./config")
const jobs = [
{
cronTime: "* * * * *", // every minutes
onTick: computeStats,
start: true,
timeZone: "Europe/Paris",
isActive: config.FEATURE_JOB_COMPUTE_STATS,
name: "Compute stats",
},
{
cronTime: "15 0 * * *", // everyday at 00:15
onTick: anonymizeConferences,
start: true,
timeZone: "Europe/Paris",
isActive: config.FEATURE_JOB_ANONYMIZE_EMAILS,
name: "Anonymize emails",
},
{
cronTime: "30 8 * * *", // everyday at 08:30
onTick: sendSurveyEmails,
start: true,
timeZone: "Europe/Paris",
isActive: Boolean(config.AFTER_MEETING_SURVEY_URL),
name: "Send survey emails",
},
{
cronTime: "0 1 * * *", // everyday at 01:00 AM
onTick: fetchCallsStats,
start: true,
timeZone: "Europe/Paris",
isActive: config.FEATURE_JOB_CALLS_STATS,
name: "Fetch statistics from past calls from OVH",
},
]
let activeJobs = 0
for (const job of jobs) {
if (job.isActive) {
console.log(`🚀 The job "${job.name}" is ON`)
new cron.CronJob(job)
activeJobs++
} else {
console.log(`❌ The job "${job.name}" is OFF`)
}
}
console.log(`Started ${activeJobs} cron jobs`)