diff options
Diffstat (limited to 'src/services/events')
-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); }; } |