all repos — caroster @ 9149587136874e250bdc8994451e13889b029762

[Octree] Group carpool to your event https://caroster.io

backend/config/functions/cron.js (view raw)

 1'use strict';
 2
 3const pMap = require('p-map');
 4const moment = require('moment');
 5
 6/**
 7 * Cron config that gives you an opportunity
 8 * to run scheduled jobs.
 9 *
10 * The cron format consists of:
11 * [SECOND (optional)] [MINUTE] [HOUR] [DAY OF MONTH] [MONTH OF YEAR] [DAY OF WEEK]
12 *
13 * See more details here: https://strapi.io/documentation/v3.x/concepts/configurations.html#cron-tasks
14 */
15
16module.exports = {
17  /**
18   * Send event recap to creators
19   * Everyday at 08:00
20   */
21  '0 8 * * *': async () => {
22    const events = await strapi.services.event.find({
23      _limit: -1,
24      date_gte: moment().toISOString(),
25    });
26    await pMap(events, strapi.services.event.sendDailyRecap, {concurrency: 5});
27  },
28};