diff --git a/packages/nocodb/src/modules/jobs/at-import/at-import.controller.ts b/packages/nocodb/src/modules/jobs/at-import/at-import.controller.ts index 4bc9827a5b..f27b7bfca8 100644 --- a/packages/nocodb/src/modules/jobs/at-import/at-import.controller.ts +++ b/packages/nocodb/src/modules/jobs/at-import/at-import.controller.ts @@ -1,32 +1,20 @@ -import { InjectQueue } from '@nestjs/bull'; import { Controller, HttpCode, Post, Request, UseGuards } from '@nestjs/common'; -import { Queue } from 'bull'; import { GlobalGuard } from '../../../guards/global/global.guard'; import { ExtractProjectIdMiddleware } from '../../../middlewares/extract-project-id/extract-project-id.middleware'; import { SyncSource } from '../../../models'; import { NcError } from '../../../helpers/catchError'; -import { QueueService } from '../fallback-queue.service'; import { JobsService } from '../jobs.service'; -import { JOBS_QUEUE, JobTypes } from '../../../interface/Jobs'; +import { JobTypes } from '../../../interface/Jobs'; @Controller() @UseGuards(ExtractProjectIdMiddleware, GlobalGuard) export class AtImportController { - activeQueue; - constructor( - @InjectQueue(JOBS_QUEUE) private readonly jobsQueue: Queue, - private readonly fallbackQueueService: QueueService, - private readonly jobsService: JobsService, - ) { - this.activeQueue = process.env.NC_REDIS_URL - ? this.jobsQueue - : this.fallbackQueueService; - } + constructor(private readonly jobsService: JobsService) {} @Post('/api/v1/db/meta/import/airtable') @HttpCode(200) async importAirtable(@Request() req) { - const job = await this.activeQueue.add(JobTypes.AtImport, { + const job = await this.jobsService.activeQueue.add(JobTypes.AtImport, { ...req.body, }); @@ -56,7 +44,7 @@ export class AtImportController { baseURL = `http://localhost:${process.env.PORT || 8080}`; } - const job = await this.activeQueue.add(JobTypes.AtImport, { + const job = await this.jobsService.activeQueue.add(JobTypes.AtImport, { syncId: req.params.syncId, ...(syncSource?.details || {}), projectId: syncSource.project_id, diff --git a/packages/nocodb/src/modules/jobs/export-import/duplicate.controller.ts b/packages/nocodb/src/modules/jobs/export-import/duplicate.controller.ts index 541ebf22a6..c7750291e7 100644 --- a/packages/nocodb/src/modules/jobs/export-import/duplicate.controller.ts +++ b/packages/nocodb/src/modules/jobs/export-import/duplicate.controller.ts @@ -1,4 +1,3 @@ -import { InjectQueue } from '@nestjs/bull'; import { Body, Controller, @@ -8,7 +7,6 @@ import { Request, UseGuards, } from '@nestjs/common'; -import { Queue } from 'bull'; import { GlobalGuard } from '../../../guards/global/global.guard'; import { Acl, @@ -17,22 +15,16 @@ import { import { ProjectsService } from '../../../services/projects.service'; import { Base, Model, Project } from '../../../models'; import { generateUniqueName } from '../../../helpers/exportImportHelpers'; -import { QueueService } from '../fallback-queue.service'; -import { JOBS_QUEUE, JobTypes } from '../../../interface/Jobs'; +import { JobsService } from '../jobs.service'; +import { JobTypes } from '../../../interface/Jobs'; @Controller() @UseGuards(ExtractProjectIdMiddleware, GlobalGuard) export class DuplicateController { - activeQueue; constructor( - @InjectQueue(JOBS_QUEUE) private readonly jobsQueue: Queue, - private readonly fallbackQueueService: QueueService, + private readonly jobsService: JobsService, private readonly projectsService: ProjectsService, - ) { - this.activeQueue = process.env.NC_REDIS_URL - ? this.jobsQueue - : this.fallbackQueueService; - } + ) {} @Post('/api/v1/db/meta/duplicate/:projectId/:baseId?') @HttpCode(200) @@ -74,7 +66,7 @@ export class DuplicateController { user: { id: req.user.id }, }); - const job = await this.activeQueue.add(JobTypes.DuplicateBase, { + const job = await this.jobsService.activeQueue.add(JobTypes.DuplicateBase, { projectId: project.id, baseId: base.id, dupProjectId: dupProject.id, @@ -123,17 +115,20 @@ export class DuplicateController { models.map((p) => p.title), ); - const job = await this.activeQueue.add(JobTypes.DuplicateModel, { - projectId: project.id, - baseId: base.id, - modelId: model.id, - title: uniqueTitle, - options, - req: { - user: req.user, - clientIp: req.clientIp, + const job = await this.jobsService.activeQueue.add( + JobTypes.DuplicateModel, + { + projectId: project.id, + baseId: base.id, + modelId: model.id, + title: uniqueTitle, + options, + req: { + user: req.user, + clientIp: req.clientIp, + }, }, - }); + ); return { id: job.id, name: job.name }; } diff --git a/packages/nocodb/src/modules/jobs/jobs.service.ts b/packages/nocodb/src/modules/jobs/jobs.service.ts index 11614d55be..1c6ae3e547 100644 --- a/packages/nocodb/src/modules/jobs/jobs.service.ts +++ b/packages/nocodb/src/modules/jobs/jobs.service.ts @@ -6,7 +6,7 @@ import { QueueService } from './fallback-queue.service'; @Injectable() export class JobsService { - activeQueue; + public activeQueue; constructor( @InjectQueue(JOBS_QUEUE) private readonly jobsQueue: Queue, private readonly fallbackQueueService: QueueService,