Debugging some issues with schedulable reservations
This commit is contained in:
parent
9dc55e09cf
commit
8dd435a950
3 changed files with 12 additions and 6 deletions
|
|
@ -41,7 +41,7 @@ export class ReservationsController {
|
|||
@Query('schedulable') schedulable?: boolean,
|
||||
) {
|
||||
if (schedulable) {
|
||||
return this.reservationsService.getScheduleable()
|
||||
return this.reservationsService.getSchedulable()
|
||||
}
|
||||
if (date) {
|
||||
return this.reservationsService.getByDate(date)
|
||||
|
|
|
|||
|
|
@ -26,8 +26,7 @@ export class ReservationsCronService {
|
|||
})
|
||||
async handleDailyReservations() {
|
||||
this.loggerService.log('handleDailyReservations beginning')
|
||||
const reservationsToPerform =
|
||||
await this.reservationService.getScheduleable()
|
||||
const reservationsToPerform = await this.reservationService.getSchedulable()
|
||||
this.loggerService.log(
|
||||
`Found ${reservationsToPerform.length} reservations to perform`,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { InjectRepository } from '@nestjs/typeorm'
|
|||
import { Repository } from 'typeorm'
|
||||
|
||||
import dayjs from '../common/dayjs'
|
||||
import { LoggerService } from '../logger/service.logger'
|
||||
import { BaanReserverenService } from '../runner/baanreserveren/service'
|
||||
import { Reservation } from './entity'
|
||||
|
||||
|
|
@ -14,6 +15,9 @@ export class ReservationsService {
|
|||
|
||||
@Inject(BaanReserverenService)
|
||||
private readonly brService: BaanReserverenService,
|
||||
|
||||
@Inject(LoggerService)
|
||||
private readonly loggerService: LoggerService,
|
||||
) {}
|
||||
|
||||
async getAll() {
|
||||
|
|
@ -35,14 +39,17 @@ export class ReservationsService {
|
|||
* Gets all reservations that have not been scheduled that are within the reservation window
|
||||
* @returns Reservations that can be scheduled
|
||||
*/
|
||||
async getScheduleable() {
|
||||
return await this.reservationsRepository
|
||||
async getSchedulable() {
|
||||
const query = this.reservationsRepository
|
||||
.createQueryBuilder()
|
||||
.where(`DATE(dateRangeStart) <= DATE(:date)`, {
|
||||
date: dayjs().add(7, 'days'),
|
||||
})
|
||||
.andWhere(`waitListed = false`)
|
||||
.getMany()
|
||||
|
||||
this.loggerService.debug('Query: ' + query.getSql())
|
||||
|
||||
return await query.getMany()
|
||||
}
|
||||
|
||||
async getByDateOnWaitingList(date = dayjs()) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue