|
|
|
@ -99,6 +99,7 @@ router.get("/timeslot", async (req: Request, res: Response) => {
|
|
|
|
WHERE
|
|
|
|
WHERE
|
|
|
|
((trainer_id = ANY($1)) OR $2)
|
|
|
|
((trainer_id = ANY($1)) OR $2)
|
|
|
|
AND (day_of_week = ANY($3))
|
|
|
|
AND (day_of_week = ANY($3))
|
|
|
|
|
|
|
|
AND (trainers.center_id = $4 OR $5)
|
|
|
|
GROUP BY
|
|
|
|
GROUP BY
|
|
|
|
weekly_timeslots.trainer_id,
|
|
|
|
weekly_timeslots.trainer_id,
|
|
|
|
users.first_name,
|
|
|
|
users.first_name,
|
|
|
|
@ -109,7 +110,9 @@ router.get("/timeslot", async (req: Request, res: Response) => {
|
|
|
|
`, [
|
|
|
|
`, [
|
|
|
|
timeslotFilters.trainer !== undefined ? timeslotFilters.trainer : [1],
|
|
|
|
timeslotFilters.trainer !== undefined ? timeslotFilters.trainer : [1],
|
|
|
|
timeslotFilters.trainer === undefined,
|
|
|
|
timeslotFilters.trainer === undefined,
|
|
|
|
weekdays
|
|
|
|
weekdays,
|
|
|
|
|
|
|
|
timeslotFilters.center,
|
|
|
|
|
|
|
|
timeslotFilters.center === undefined
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
const databaseResult: DatabaseResult[] = queryResult.rows;
|
|
|
|
const databaseResult: DatabaseResult[] = queryResult.rows;
|
|
|
|
@ -129,6 +132,20 @@ router.get("/timeslot", async (req: Request, res: Response) => {
|
|
|
|
timeslots: for (const timeslot of trainer.timeslots) {
|
|
|
|
timeslots: for (const timeslot of trainer.timeslots) {
|
|
|
|
if (timeslot.day_of_week !== weekDay)
|
|
|
|
if (timeslot.day_of_week !== weekDay)
|
|
|
|
continue timeslots;
|
|
|
|
continue timeslots;
|
|
|
|
|
|
|
|
if (timeslotFilters.startTime) {
|
|
|
|
|
|
|
|
if (parseInt(timeslotFilters.startTime.split(":")[0]) > parseInt(timeslot.start_time.split(":")[0]))
|
|
|
|
|
|
|
|
continue timeslots;
|
|
|
|
|
|
|
|
if (timeslotFilters.startTime.split(":")[0] === timeslot.start_time.split(":")[0] &&
|
|
|
|
|
|
|
|
parseInt(timeslotFilters.startTime.split(":")[1]) > parseInt(timeslot.start_time.split(":")[1]))
|
|
|
|
|
|
|
|
continue timeslots;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (timeslotFilters.endTime) {
|
|
|
|
|
|
|
|
if (parseInt(timeslotFilters.endTime.split(":")[0]) < parseInt(timeslot.end_time.split(":")[0]))
|
|
|
|
|
|
|
|
continue timeslots;
|
|
|
|
|
|
|
|
if (timeslotFilters.endTime.split(":")[0] === timeslot.end_time.split(":")[0] &&
|
|
|
|
|
|
|
|
parseInt(timeslotFilters.endTime.split(":")[1]) < parseInt(timeslot.end_time.split(":")[1]))
|
|
|
|
|
|
|
|
continue timeslots;
|
|
|
|
|
|
|
|
}
|
|
|
|
const startTime = day.clone()
|
|
|
|
const startTime = day.clone()
|
|
|
|
.hour(parseInt(timeslot.start_time.split(":")[0]))
|
|
|
|
.hour(parseInt(timeslot.start_time.split(":")[0]))
|
|
|
|
.minute(parseInt(timeslot.start_time.split(":")[1]))
|
|
|
|
.minute(parseInt(timeslot.start_time.split(":")[1]))
|
|
|
|
|