diff options
author | eug-vs <eug-vs@keemail.me> | 2020-11-14 17:21:21 +0300 |
---|---|---|
committer | eug-vs <eug-vs@keemail.me> | 2020-11-14 17:21:21 +0300 |
commit | ae94313667b3abe257c0767439c6d3986ba0fde6 (patch) | |
tree | 212e5082cda719c1d26625b251d60452aea275ab /src/services | |
parent | 4f0561acef93970f69b0ddda1cea132532355e7d (diff) | |
download | bsu-fantom-ae94313667b3abe257c0767439c6d3986ba0fde6.tar.gz |
feat: launch session on schedule for many users
Diffstat (limited to 'src/services')
-rw-r--r-- | src/services/events/event.service.js | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/services/events/event.service.js b/src/services/events/event.service.js index 5c5bcff..accd45d 100644 --- a/src/services/events/event.service.js +++ b/src/services/events/event.service.js @@ -1,11 +1,13 @@ const Agenda = require('agenda'); const { getConnection } = require('../../connectDb.js'); +const handleAttendClassJob = require('../../handlers'); class Events { setup(app) { this.collectionName = 'events'; + // Reuse mongoose connection const connection = getConnection(); this.agenda = new Agenda(); this.agenda.mongo( @@ -13,20 +15,14 @@ class Events { this.collectionName ); - this.defineJobs(); + // Define jobs + this.agenda.define('attend class', handleAttendClassJob); return this.agenda.start(); }; - defineJobs() { - this.agenda.define('attend class', async job => { - console.log('Running attend class job with attrs:'); - console.log(job.attrs); - }); - }; - async create(data, params) { - return this.agenda.schedule(data.date, 'attend class', { data }); + return this.agenda.schedule(data.date, 'attend class', data); }; } |