expose workshop metric

This commit is contained in:
2024-11-26 18:07:03 +07:00
parent 1062f5944d
commit e63f900cf4
3 changed files with 15 additions and 2 deletions

View File

@@ -94,10 +94,10 @@ export class CronService {
@Cron(CronExpression.EVERY_MINUTE)
async handleRefundTicket() {
Logger.log('Handling refund ticket', 'handleRefundTicket')
// get all orders where status is PENDING_REFUND or REFUNDED and has schedule.dates in future
// get all orders where status is REFUNDED and has schedule.dates in future
const orders = await this.prisma.order.findMany({
where: {
status: { in: [OrderStatus.PENDING_REFUND, OrderStatus.REFUNDED] },
status: OrderStatus.REFUNDED,
schedule: {
dates: {
some: {

View File

@@ -116,6 +116,7 @@ export class RefundTicketSchema extends PothosSchema {
let refundAmount = 0
if (diffDays < 24) refundAmount = order.total
else if (diffDays < 48) refundAmount = order.total * 0.5
if (refundAmount === 0) throw new Error('Cannot refund after 72 hours')
// create refund ticket
const refundTicket = await this.prisma.refundTicket.create({
data: {

View File

@@ -35,6 +35,18 @@ export class WorkshopSchema extends PothosSchema {
serviceId: t.exposeID('serviceId', {
description: 'The ID of the service that the workshop is for.',
}),
expectedParticipants: t.exposeInt('expectedParticipants', {
description: 'The expected number of participants for the workshop.',
}),
minParticipants: t.exposeInt('minParticipants', {
description: 'The minimum number of participants for the workshop.',
}),
registeredParticipants: t.exposeInt('registeredParticipants', {
description: 'The number of participants registered for the workshop.',
}),
actualParticipants: t.exposeInt('actualParticipants', {
description: 'The number of participants actually attending the workshop.',
}),
imageFile: t.relation('imageFile', {
nullable: true,
}),