From da2e354675092871cc6a8e928f0178b45a305d06 Mon Sep 17 00:00:00 2001 From: michellelin1 Date: Wed, 27 Mar 2024 21:46:03 -0700 Subject: [PATCH] fixed season cut off --- common/utils.js | 10 ++-------- routes/publishedSchedule.js | 13 +++---------- server/schema/catalog.sql | 2 +- 3 files changed, 6 insertions(+), 19 deletions(-) diff --git a/common/utils.js b/common/utils.js index 7eec2d9..2ba4fef 100644 --- a/common/utils.js +++ b/common/utils.js @@ -95,16 +95,10 @@ const keysToCamel = (data) => { }; const getSeasonFromMonthAndYear = (month, year) => { - if (month === 11) { - return `Winter ${year + 1}`; - } - if (month === 0 || month === 1) { - return `Winter ${year}`; - } // spring // march-may -> winter [year] - if (month >= 2 && month <= 4) { - return `Winter ${year}`; + if (month >= 0 && month <= 4) { + return `Spring ${year}`; } // summer // june-august -> summer [year] diff --git a/routes/publishedSchedule.js b/routes/publishedSchedule.js index 91117ed..1e090ce 100644 --- a/routes/publishedSchedule.js +++ b/routes/publishedSchedule.js @@ -136,22 +136,15 @@ publishedScheduleRouter.get('/season', async (req, res) => { const { season, year } = req.query; // getting the intervals for each season - if (season.toLowerCase() === 'winter') { - startTime = `${year - 1}-12-01`; - if ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0) { - endTime = `${year}-02-29`; - } else { - endTime = `${year}-02-28`; - } - } else if (season.toLowerCase() === 'spring') { - startTime = `${year}-03-01`; + if (season.toLowerCase() === 'spring') { + startTime = `${year}-01-01`; endTime = `${year}-05-31`; } else if (season.toLowerCase() === 'summer') { startTime = `${year}-06-01`; endTime = `${year}-08-31`; } else { startTime = `${year}-09-01`; - endTime = `${year}-11-30`; + endTime = `${year}-12-31`; } const seasonResult = await db.query( diff --git a/server/schema/catalog.sql b/server/schema/catalog.sql index e32df3e..a2a19be 100644 --- a/server/schema/catalog.sql +++ b/server/schema/catalog.sql @@ -1,7 +1,7 @@ CREATE TYPE event AS ENUM ('guest speaker', 'study-trip', 'workshop', 'other'); CREATE TYPE subject AS ENUM ('life skills', 'science', 'technology', 'engineering', 'math', 'college readiness'); CREATE TYPE year AS ENUM ('junior', 'senior', 'both'); -CREATE TYPE season AS ENUM ('spring', 'summer', 'fall', 'winter'); +CREATE TYPE season AS ENUM ('spring', 'summer', 'fall'); DROP TABLE IF EXISTS catalog; CREATE TABLE catalog (