Skip to content

Commit

Permalink
fixed season cut off
Browse files Browse the repository at this point in the history
  • Loading branch information
michellelin1 committed Mar 28, 2024
1 parent 30705fc commit da2e354
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 19 deletions.
10 changes: 2 additions & 8 deletions common/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
13 changes: 3 additions & 10 deletions routes/publishedSchedule.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion server/schema/catalog.sql
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down

0 comments on commit da2e354

Please sign in to comment.