Skip to content

Add smart filters, propagate venue data, and improve timetable filtering performance#170

Open
upayanmazumder wants to merge 7 commits into
CodeChefVIT:updatesfrom
upayanmazumder-DevLabs:filters
Open

Add smart filters, propagate venue data, and improve timetable filtering performance#170
upayanmazumder wants to merge 7 commits into
CodeChefVIT:updatesfrom
upayanmazumder-DevLabs:filters

Conversation

@upayanmazumder
Copy link
Copy Markdown
Member

@upayanmazumder upayanmazumder commented Oct 27, 2025

This pull request introduces smart filtering capabilities for generated timetables, propagates venue data throughout the application, and includes several performance and maintainability improvements.

Smart Filters

Three toggle-based smart filters have been added to the timetable view to help users narrow down results:

  • Same Building: Filters timetables where all classrooms share the same building. The building is determined solely from the alphabetical prefix of venue strings (e.g., "SJT" from "SJT 305"). If any entry lacks venue data, or if the extracted building prefixes are not all identical, the timetable is excluded. No heuristic fallback is used -- the filter is purely venue-driven.
  • Close: Filters timetables whose classrooms are numerically close in room number. Room numbers are extracted via the first numeric group in each venue string (e.g., "305" from "SJT 305"), and the timetable qualifies if the spread between the smallest and largest room number is within a configurable threshold (currently 30). Timetables with no venue data or no parsable room numbers do not qualify.
  • No Mix: Filters timetables that exclusively contain either morning or evening slots, omitting timetables that combine both. Theory slots ending in "1" and lab slots L1-L30 are considered morning; theory slots ending in "2" and lab slots L31-L60 are considered evening.

The filter evaluation logic has been extracted into a dedicated module (src/lib/filterUtils.ts) with named constants, eliminating approximately 60 lines of duplicated code that previously existed between the active filter computation and the precomputed match-count logic.

Venue Data

The venue field has been added as an optional property to the timetableDisplayData and fullCourseData types. It is now propagated from subject data through the course selection flow (FacultySelector.tsx), timetable generation (utils.ts), timetable display (ViewTimeTable.tsx), and the compound table component (CompoundTable.tsx). This enables venue-aware filtering and positions the application for future venue display features.

Performance and Correctness

  • originalTimetableData, allTimetables, and facultyList are now wrapped in useMemo to prevent unnecessary recomputation on each render cycle.
  • The faculty filter is reset when timetable data changes, preventing a stale filter state from silently producing an empty result set.
  • Pagination operates on the filtered display list rather than the raw index, resolving a mismatch that could occur when navigating while a smart filter is active.

UI Refinements

  • A smart filter toolbar displays match counts for each filter and shows or hides filter buttons dynamically based on whether they would produce meaningful results.
  • Pagination buttons reference the filtered index list, ensuring that navigation remains consistent with the active filter context.
  • Action buttons (Share, Download, Save) are conditionally rendered only when a timetable is selected.
  • CompoundTable layout has been improved with responsive flex spacing, text truncation, and refined column widths.
  • A global button cursor pointer style has been applied.

@atharvaSharma17 atharvaSharma17 changed the base branch from prod to updates June 3, 2026 19:16
@atharvaSharma17 atharvaSharma17 self-requested a review June 3, 2026 19:18
@upayanmazumder upayanmazumder changed the title Smart Filters Add smart filters, propagate venue data, and improve timetable filtering performance Jun 4, 2026
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.

1 participant