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