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