Skip to content

Commit

Permalink
Add agenda queue indexes on init
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandro-bulgaris-qcif committed Jun 26, 2024
1 parent f5b3150 commit b088fdd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion typescript/api/services/AgendaQueueService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,12 @@ export module Services {
_.forOwn(sails.config.agendaQueue.options, (optionVal:any, optionName:string) => {
this.setOptionIfDefined(agendaOpts, optionName, optionVal);
});
const dbManager = User.getDatastore().manager;
const collectionName = _.get(agendaOpts, 'collection', 'agendaJobs');
await dbManager.collection(collectionName).createIndex({ name: 1, disabled: 1, lockedAt: 1, nextRunAt: 1 })
await dbManager.collection(collectionName).createIndex({ name: -1, disabled: -1, lockedAt: -1, nextRunAt: -1})
if (_.isEmpty(_.get(agendaOpts, 'db.address'))) {
agendaOpts['mongo'] = User.getDatastore().manager;
agendaOpts['mongo'] = dbManager;
}
this.agenda = new Agenda(agendaOpts);
this.defineJobs(sails.config.agendaQueue.jobs);
Expand Down

0 comments on commit b088fdd

Please sign in to comment.