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 22 23 24 25 26 27 28 29 30 31 32 33 34 | 12x 12x 12x 12x 12x 12x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { Processor, WorkerHost } from '@nestjs/bullmq';
import { Job } from 'bullmq';
import { Injectable, Logger } from '@nestjs/common';
import { PrismaService } from '@app/modules/prisma/prisma.service';
import { InjectQueue } from '@nestjs/bullmq';
import { Queue } from 'bullmq';
interface EndPayload { requestId: number }
@Processor('quick-rent:end-bid-window')
@Injectable()
export class QuickRentEndBidProcessor extends WorkerHost {
private readonly logger = new Logger(QuickRentEndBidProcessor.name);
constructor(private readonly prisma: PrismaService, @InjectQueue('quick-rent:payment-window-expired') private readonly paymentExpiredQueue: Queue) { super(); }
async process(job: Job<EndPayload>): Promise<void> {
const { requestId } = job.data;
const req = await this.prisma.client.quickRentRequest.findUnique({ where: { id: requestId } });
Iif (!req || req.status !== 'OPEN') return;
const top = await this.prisma.client.quickRentBid.findFirst({
where: { requestId },
orderBy: [{ amountCents: 'desc' }, { createdAt: 'asc' }],
});
Iif (!top) {
await this.prisma.client.quickRentRequest.update({ where: { id: requestId }, data: { status: 'EXPIRED' } });
return;
}
await this.prisma.client.quickRentRequest.update({ where: { id: requestId }, data: { status: 'AWARDED', winnerBidId: top.id } });
// Add delayed job for payment window expiry check for rank 1
await this.paymentExpiredQueue.add('check', { requestId, bidId: top.id, rank: 1 }, { delay: 60 * 60 * 1000 });
}
}
|