schedule - skip empty shifts

This commit is contained in:
Dobromir Popov
2024-03-06 10:00:49 +02:00
parent f66ec1adaa
commit acc5983c5f

View File

@ -95,6 +95,9 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
lt: toDate, lt: toDate,
}, },
}, },
orderBy: {
startTime: 'asc',
},
include: { include: {
assignments: { assignments: {
where: {}, where: {},
@ -147,7 +150,9 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
.join(", "), .join(", "),
}; };
groupedShifts[day][time].push(shiftSchedule); if (shiftSchedule.names.length > 0) {
groupedShifts[day][time].push(shiftSchedule);
}
} }
} catch (err) { } catch (err) {
console.log(err + " " + JSON.stringify(shifts[i])); console.log(err + " " + JSON.stringify(shifts[i]));
@ -188,8 +193,9 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
dayEvent.shifts.push(...groupedShifts[day][time]); dayEvent.shifts.push(...groupedShifts[day][time]);
} }
if (dayEvent) {
monthlySchedule.events.push(dayEvent); monthlySchedule.events.push(dayEvent);
}
} }
const outputPath = path.join(process.cwd(), 'public', 'content', 'output'); const outputPath = path.join(process.cwd(), 'public', 'content', 'output');