Skip to content

DEV-177: Add Support for Time Filtering in Backend - #385

Merged
gyang148 merged 10 commits into
previewfrom
dev177_timefiltering
Oct 2, 2026
Merged

gyang148 merged 10 commits into
previewfrom
dev177_timefiltering

Conversation

@gyang148

@gyang148 gyang148 commented Dec 4, 2025

Copy link
Copy Markdown
Collaborator

References

Proposed Changes

  • changed search_courses to take start and end times for filtering in the form of a string : HH:MM:SS
  • passes these filters into the helper, which parses it into an ISO formatted time.
  • Wrote a helper function called course_fits_time_constraint(course, start_time, end_time, term) which takes in a course, the current term, and the restrictions on time and returns whether or not a student can take this course during the restricted times

Some Notes

  • There are a lot of temporary loggers in the backend + I temporarily directly passed in a start time and end time straight into the query builder in the front end solely for testing purposes (because we don't have the frontend component yet). So far, it seems like the code is working but I may not have covered all edge cases. I will remove these once we determine that the code is okay.

@linear

linear Bot commented Dec 4, 2025

Copy link
Copy Markdown

@vercel

vercel Bot commented Dec 4, 2025 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
plan Ready Ready Preview Oct 2, 2026 10:40pm UTC

Request Review

@gyang148

Copy link
Copy Markdown
Collaborator Author

Changes: simplified the search to adhere to Spencer's suggestion: simplify the time filtering to only do it based on the lectures for the class and not even worry about whether the precepts/labs/etc fit in the query time., take into account lectures, seminars, and studios

@hannahchoi05
hannahchoi05 changed the base branch from main to preview January 29, 2026 02:28

@hannahchoi05 hannahchoi05 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few comments!

Comment thread backend/hoagieplan/api/dashboard/search.py Outdated
sections = Section.objects.filter(course=course,
term__term_code=term).prefetch_related('classmeeting_set')
else:
sections = course.section_set.all()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use prefetch_related; all() can cause inefficient queries.

if not class_meetings:
continue

meeting = class_meetings[0]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For courses like SML201, there are 2 lectures. Instead of just using class_meetings[0] we want to iterate over all instances of that class_meeting to check times.

if not sections:
return False

primary_types = ["Lecture", "Seminar", "Studio"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See ECS389, CWR343, CWR202, etc. (almost all CWR courses). I think we should include 'Class' in this as well.

# Parse start_time and end_time
try:
start_time = dtime.fromisoformat(start_time_str)
except Exception:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this line (and line 109), we should use ValueError instead of Exception for clarity.

Comment thread frontend/app/calendar/CalendarSearch.tsx
@issacli-0821

Copy link
Copy Markdown
Collaborator

@gyang148 Merge conflicts here!

Signed-off-by: Gary Yang <GY4937@princeton.edu>
@gyang148
gyang148 merged commit 9430c63 into preview Oct 2, 2026
3 of 4 checks passed

This branch was successfully deployed

1 active deployment
Preview — b39bc3e4 Deployed Oct 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants