nusmods icon indicating copy to clipboard operation
nusmods copied to clipboard

fix(optimiser): Prevent invalid time range

Open sevensxyt opened this issue 5 months ago • 5 comments

Context

On the optimiser page, time options for the dropdown lists are not filtered. This allows invalid time ranges to be selected, where the start time is after the end time, as shown below:

image

Start time 18:00 is after end time 14:00

Implementation

  • I've abstracted the time ranges into constants, and stored the start/end times for class/lunch as state
  • When start time is selected, we filter out end times to include options that are after start time
  • This prevents users from selecting an invalid range where start time is after end time, as shown below:
image

Other Information

I've also added tests for the utility functions added

image

sevensxyt avatar Jul 20 '25 06:07 sevensxyt

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

Project Deployment Preview Comments Updated (UTC)
nusmods-export Ready Ready Preview Comment Aug 18, 2025 0:06am
nusmods-website Ready Ready Preview Comment Aug 18, 2025 0:06am

vercel[bot] avatar Jul 20 '25 06:07 vercel[bot]

@sevensxyt is attempting to deploy a commit to the modsbot's projects Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Jul 20 '25 06:07 vercel[bot]

Codecov Report

:x: Patch coverage is 23.07692% with 20 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 52.91%. Comparing base (988c6fd) to head (94ea529). :warning: Report is 137 commits behind head on master.

Files with missing lines Patch % Lines
website/src/views/optimiser/OptimiserForm.tsx 0.00% 20 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4113      +/-   ##
==========================================
- Coverage   54.52%   52.91%   -1.62%     
==========================================
  Files         274      289      +15     
  Lines        6076     6696     +620     
  Branches     1455     1633     +178     
==========================================
+ Hits         3313     3543     +230     
- Misses       2763     3153     +390     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Jul 20 '25 06:07 codecov[bot]

Hi @sevensxyt, thanks for the PR. I'm currently working on a refactor of the optimiser component in #4094, and it also modifies the time select. I'll update you again when those changes are ready.

leslieyip02 avatar Jul 20 '25 12:07 leslieyip02

Hi @sevensxyt, #4094 has been merged.

Let me know if you are still interested in working on this. Thanks for your patience and sorry for the delay!

leslieyip02 avatar Oct 19 '25 00:10 leslieyip02