This commit is contained in:
2024-06-10 19:35:04 +05:00
parent 7e692fee4c
commit ac1a705187
11 changed files with 298 additions and 70 deletions
+1 -21
View File
@@ -221,29 +221,9 @@ scheduledSessionsRouter.put("/:id", async (req, res) => {
const scheduledSessionId = req.params.id;
let {
startAt,
endAt,
activeSessionId,
}: { startAt: string; endAt: string; activeSessionId: string } = req.body;
if (!startAt && !endAt) {
return res.json({
status: "error",
message: "Parameter `startAt` or `duration` is required, or both",
});
}
if (startAt && !isValid(parseISO(startAt))) {
return res.json({
status: "error",
message: "Invalid value of the `startAt` parameter",
});
}
// function isInteger(num: number) {
// return (num ^ 0) === num;
// }
const scheduledSession = await ScheduledSession.findById(scheduledSessionId);
if (!scheduledSession) {
@@ -256,7 +236,7 @@ scheduledSessionsRouter.put("/:id", async (req, res) => {
try {
const scheduledSession = await ScheduledSession.findByIdAndUpdate(
scheduledSessionId,
{ startAt, endAt, activeSessionId },
{ activeSessionId },
{ new: true }
);
+1 -3
View File
@@ -7,12 +7,11 @@ schedulesRouter.get(
"/companies/:companyId/builds/:buildId",
async (req, res) => {
const { companyId, buildId } = req.params;
const date = new Date();
// const date = new Date();
const schedules = await Schedule.find({
companyId,
buildId,
startDate: { $lte: date },
});
if (!schedules.length) {
@@ -24,7 +23,6 @@ schedulesRouter.get(
const schedule = await Schedule.findOne({
companyId,
buildId,
startDate: { $lte: date },
});
res.json(schedule);