Skip to content

Commit 388fe2a

Browse files
Fix bugs with calendar and session status/renewal date filtering
1 parent 096b4da commit 388fe2a

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

backend/src/controllers/session.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ const createMissingRegularSessions = async () => {
101101
"sessionTime.start_time": session.start_time,
102102
"sessionTime.end_time": session.end_time,
103103
schedule: dayOfWeek,
104+
status: "Joined",
104105
startDate: { $lte: new Date(date) },
106+
renewalDate: { $gte: new Date(date) },
105107
programId: program._id,
106108
});
107109
if (enrollments.length === 0) {
@@ -205,6 +207,8 @@ const createMissingVaryingSessions = async () => {
205207
const enrollmentsThisDate = await EnrollmentModel.find({
206208
programId: program._id,
207209
startDate: { $lte: new Date(date) },
210+
status: "Joined",
211+
renewalDate: { $gte: new Date(date) },
208212
})
209213
.lean()
210214
.exec();

frontend/src/components/Calendar/util.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ export const generateDates = (month: number, year: number, calendar?: CalendarRe
2626
for (const c of calendar.calendar) {
2727
const calendarDate = new Date(c.date);
2828
if (
29-
calendarDate.getMonth() === date.getMonth() &&
30-
calendarDate.getDate() === date.getDate() &&
31-
calendarDate.getFullYear() === date.getFullYear()
29+
calendarDate.getUTCMonth() === date.getMonth() &&
30+
calendarDate.getUTCDate() === date.getDate() &&
31+
calendarDate.getUTCFullYear() === date.getFullYear()
3232
) {
3333
hours = c.hours;
3434
session = c.session;
@@ -53,9 +53,9 @@ export const generateDates = (month: number, year: number, calendar?: CalendarRe
5353
for (const c of calendar.calendar) {
5454
const calendarDate = new Date(c.date);
5555
if (
56-
calendarDate.getMonth() === date.getMonth() &&
57-
calendarDate.getDate() === date.getDate() &&
58-
calendarDate.getFullYear() === date.getFullYear()
56+
calendarDate.getUTCMonth() === date.getMonth() &&
57+
calendarDate.getUTCDate() === date.getDate() &&
58+
calendarDate.getUTCFullYear() === date.getFullYear()
5959
) {
6060
hours = c.hours;
6161
session = c.session;
@@ -82,9 +82,9 @@ export const generateDates = (month: number, year: number, calendar?: CalendarRe
8282
for (const c of calendar.calendar) {
8383
const calendarDate = new Date(c.date);
8484
if (
85-
calendarDate.getMonth() === date.getMonth() &&
86-
calendarDate.getDate() === date.getDate() &&
87-
calendarDate.getFullYear() === date.getFullYear()
85+
calendarDate.getUTCMonth() === date.getMonth() &&
86+
calendarDate.getUTCDate() === date.getDate() &&
87+
calendarDate.getUTCFullYear() === date.getFullYear()
8888
) {
8989
hours = c.hours;
9090
session = c.session;

0 commit comments

Comments
 (0)