upd
This commit is contained in:
@@ -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 }
|
||||
);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user