Adding cron to clean up expired reservations
This commit is contained in:
parent
89948e79f4
commit
839c162f1f
1 changed files with 14 additions and 0 deletions
|
|
@ -33,4 +33,18 @@ export class ReservationsCronService {
|
||||||
reservationsToPerform.map((r) => ({ data: r })),
|
reservationsToPerform.map((r) => ({ data: r })),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Cron(CronExpression.EVERY_DAY_AT_11PM, {
|
||||||
|
name: 'cleanUpExpiredReservations',
|
||||||
|
timeZone: 'Europe/Amsterdam',
|
||||||
|
})
|
||||||
|
async cleanUpExpiredReservations() {
|
||||||
|
const reservations = await this.reservationService.getByDate()
|
||||||
|
this.loggerService.log(
|
||||||
|
`Found ${reservations.length} reservations to delete`,
|
||||||
|
)
|
||||||
|
for (const reservation of reservations) {
|
||||||
|
await this.reservationService.deleteById(reservation.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue