All files / src/modules/boost boost-expiry.processor.ts

54.54% Statements 6/11
75% Branches 3/4
0% Functions 0/2
44.44% Lines 4/9

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 2111x   11x 11x           11x                      
import { Processor, WorkerHost } from '@nestjs/bullmq';
import { Job } from 'bullmq';
import { BoostService } from '@app/modules/boost/boost.service';
import { Injectable, Logger } from '@nestjs/common';
 
interface EmptyPayload {}
 
@Processor('boost-expiry')
@Injectable()
export class BoostExpiryProcessor extends WorkerHost {
  private readonly logger = new Logger(BoostExpiryProcessor.name);
 
  constructor(private readonly boostService: BoostService) {
    super();
  }
 
  async process(_job: Job<EmptyPayload>): Promise<void> {
    const count = await this.boostService.expireBoosts();
    this.logger.log(`Expired ${count} boosts`);
  }
}