All files / src/modules/listings bulk-import.processor.ts

0% Statements 0/11
0% Branches 0/4
0% Functions 0/2
0% Lines 0/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21                                         
import { Processor, WorkerHost } from '@nestjs/bullmq';
import { Job } from 'bullmq';
import { Injectable, Logger } from '@nestjs/common';
import { PrismaService } from '@app/modules/prisma/prisma.service';
 
interface BulkImportPayload { userId: number; csvKey: string }
 
@Processor('listings-bulk-import')
@Injectable()
export class ListingsBulkImportProcessor extends WorkerHost {
  private readonly logger = new Logger(ListingsBulkImportProcessor.name);
  constructor(private readonly prisma: PrismaService) { super(); }
  async process(job: Job<BulkImportPayload>): Promise<void> {
    const { userId, csvKey } = job.data;
    this.logger.log(`Processing bulk import for user ${userId} from ${csvKey}`);
    // TODO: download CSV from storage, parse, create listings in batches with transactions
  }
}