@@ -3,18 +3,20 @@ import asyncHandler from "../middleware/asyncHandler";
33import { supabase } from "../db/setupDb" ;
44import { start } from "repl" ;
55
6- function getReadingWeekStart ( start_date :string ) {
7- return ( start_date === "2025-05-02" ) ? "2025-06-15"
8- : ( start_date === "2025-09-02" ) ? "2025-10-26"
9- : "2026-02-16" ;
10-
6+ function getReadingWeekStart ( start_date : string ) {
7+ return start_date === "2025-05-02"
8+ ? "2025-06-15"
9+ : start_date === "2025-09-02"
10+ ? "2025-10-26"
11+ : "2026-02-16" ;
1112}
1213
13- function getReadingWeekEnd ( start_date :string ) {
14- return ( start_date === "2025-05-02" ) ? "2025-06-22"
15- : ( start_date === "2025-09-02" ) ? "2025-11-01"
16- : "2026-02-22" ;
17-
14+ function getReadingWeekEnd ( start_date : string ) {
15+ return start_date === "2025-05-02"
16+ ? "2025-06-22"
17+ : start_date === "2025-09-02"
18+ ? "2025-11-01"
19+ : "2026-02-22" ;
1820}
1921/**
2022 * Helper method to generate weekly course events.
@@ -79,10 +81,13 @@ export function generateWeeklyCourseEvents(
7981 FR : 5 ,
8082 SA : 6 ,
8183 } ;
82-
83- const rw_start = new Date ( getReadingWeekStart ( semester_start_date ) + "T00:00:00-05:00" ) ;
84- const rw_end = new Date ( getReadingWeekEnd ( semester_start_date ) + "T00:00:00-05:00" ) ;
8584
85+ const rw_start = new Date (
86+ getReadingWeekStart ( semester_start_date ) + "T00:00:00-05:00" ,
87+ ) ;
88+ const rw_end = new Date (
89+ getReadingWeekEnd ( semester_start_date ) + "T00:00:00-05:00" ,
90+ ) ;
8691
8792 const targetWeekday = weekdayMap [ courseDay ] ;
8893 if ( targetWeekday === undefined ) {
@@ -108,19 +113,19 @@ export function generateWeeklyCourseEvents(
108113 let eventsToInsert : any [ ] = [ ] ;
109114 //Loop through the semester, adding an event for each week on the targeted weekday
110115 while ( currentDate <= semesterEndObj ) {
111- if ( currentDate < rw_start || currentDate > rw_end ) {
112- eventsToInsert . push ( {
113- user_id,
114- calendar_id,
115- event_name : courseEventName ,
116- //Convert the occurrence of date to YYYY-MM-DD format
117- event_date : currentDate . toISOString ( ) . split ( "T" ) [ 0 ] ,
118- event_start : courseStartTime ,
119- event_end : courseEndTime ,
120- event_description : null ,
121- offering_id,
122- } ) ;
123- }
116+ if ( currentDate < rw_start || currentDate > rw_end ) {
117+ eventsToInsert . push ( {
118+ user_id,
119+ calendar_id,
120+ event_name : courseEventName ,
121+ //Convert the occurrence of date to YYYY-MM-DD format
122+ event_date : currentDate . toISOString ( ) . split ( "T" ) [ 0 ] ,
123+ event_start : courseStartTime ,
124+ event_end : courseEndTime ,
125+ event_description : null ,
126+ offering_id,
127+ } ) ;
128+ }
124129 //Cycle to the next week
125130 currentDate . setDate ( currentDate . getDate ( ) + 7 ) ;
126131 }
0 commit comments