Skip to content

Commit

Permalink
converted from type timestamp to time for published_schedule
Browse files Browse the repository at this point in the history
  • Loading branch information
h0ethan04 committed Feb 13, 2024
1 parent dbf6ed8 commit 27c2342
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions routes/publishedSchedule.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ publishedScheduleRouter.post('/', async (req, res) => {
`
UPDATE day
SET
start_time = CASE WHEN $1::timestamp < start_time THEN $1::timestamp ELSE start_time END,
end_time = CASE WHEN $2::timestamp > end_time THEN $2::timestamp ELSE end_time END
start_time = CASE WHEN $1 < start_time THEN $1 ELSE start_time END,
end_time = CASE WHEN $2 > end_time THEN $2 ELSE end_time END
WHERE id = $3;
`,
[startTime, endTime, dayId],
Expand Down Expand Up @@ -392,14 +392,14 @@ publishedScheduleRouter.delete('/:id', async (req, res) => {
await db.query(`DELETE FROM day WHERE id = $1`, [dayId]);
} else {
// if the event start time was the earliest change to earliest in PS table for that day
if (startTime.getTime() === dayResult.startTime.getTime()) {
if (startTime === dayResult.startTime) {
await db.query(
`UPDATE day SET start_time = (SELECT MIN(start_time) FROM published_schedule WHERE day_id = $1) WHERE id = $1`,
[dayId],
);
}
// if the event end time was the latest change to latest in PS table for that day
if (endTime.getTime() === dayResult.endTime.getTime()) {
if (endTime === dayResult.endTime) {
await db.query(
`UPDATE day SET end_time = (SELECT MAX(end_time) FROM published_schedule WHERE day_id = $1) WHERE id = $1`,
[dayId],
Expand Down
4 changes: 2 additions & 2 deletions server/schema/published_schedule.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ CREATE TABLE IF NOT EXISTS published_schedule (
day_id integer NOT NULL,
confirmed boolean NOT NULL,
confirmed_on date NOT NULL,
start_time timestamp NOT NULL,
end_time timestamp NOT NULL,
start_time time NOT NULL,
end_time time NOT NULL,
cohort varchar[] NOT NULL,
notes varchar(100),
FOREIGN KEY (event_id)
Expand Down

0 comments on commit 27c2342

Please sign in to comment.