+
+ const counts = await queue.getJobCounts()
+
+ total += counts[state]
+ }
+
+ return total
+ }
+
+ async removeOldJobs () {
+ for (const key of Object.keys(this.queues)) {
+ const queue = this.queues[key]
+ await queue.clean(JOB_COMPLETED_LIFETIME, 'completed')
+ }
+ }
+
+ private addRepeatableJobs () {
+ this.queues['videos-views'].add({}, {
+ repeat: REPEAT_JOBS['videos-views']
+ }).catch(err => logger.error('Cannot add repeatable job.', { err }))
+ }
+
+ private filterJobTypes (jobType?: JobType) {
+ if (!jobType) return jobTypes
+
+ return jobTypes.filter(t => t === jobType)