-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix avail command bugs and add test cases #351
Fix avail command bugs and add test cases #351
Conversation
…ay class if current time past timeRange
Add basic test cases (not complete) Add UniqueStudentList revamped code (not complete) Update `TeachersPet::findAvailableClass` for the purpose of testing
Adds consideration of endTime if 12AM is stored as LocalTime.of(0, 0). As a result of this, the checks for the timeRange will always fail, and so I have written logic such that if the endTime is at 12AM, it will just `continue`.
…into fix-avail-command-bugs * 'master' of https://github.com/AY2223S1-CS2103T-T09-4/tp: Update java doc description for compare to methods Fix small ui initialization bug Remove spacing from 2 lines Refine parts of DG Fill in rest of PPP Fix inaccurate fields for Student Add javadoc comment Fix command messages Fix checkstyle bugs Add tests Fix student sharing same phone as NOK bug in edit command Fix student sharing same phone as NOK bug in add command Update uml diagrams to Teachers Pet Update png files to current project specifications Refactor uml diagrams to Teachers Pet Replace DG-images for student to person refactor
edit 1 dt/2022-11-06 0900-1000 edit 2 dt/2022-11-08 1000-1100 edit 3 dt/2022-11-07 1000-1100 avail 0900-1030 61 expect 2022-11-09 0900-1001 as return
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am still reading the code now and have released the above comments so that you can work on them while I review.
src/main/java/seedu/address/model/student/UniqueStudentList.java
Outdated
Show resolved
Hide resolved
src/main/java/seedu/address/model/student/UniqueStudentList.java
Outdated
Show resolved
Hide resolved
.filter(student -> student.getDisplayedClass().startTime != null | ||
&& student.getDisplayedClass().endTime != null | ||
&& student.getDisplayedClass().date != null | ||
&& student.getDisplayedClass().date.compareTo(currDate) == 0) | ||
.sorted(Student::compareToByClassAsc) | ||
.map((element) -> element.getDisplayedClass()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After the merge of Caden's PR to remove displayClass
field, this part needs to be changed accordingly.
[Missed Corner Case] At the current timing of "1730", with only one class set to be "2022-11-06 1630-1830", when calling the "avail 1630-1930 61", it will give a result of "Available date is: 2022-11-06 1830-1931" which is out of the given range.
if (endTimeFromTr.compareTo(classToCompare.startTime) <= 0) { | ||
newClass = new Class(currDate, startTimeFromTr, endTimeFromTr); | ||
} | ||
} else if (currTime.compareTo(classToCompare.startTime) >= 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the condition in line 617 can be directly derived from negation of line 613 and can be simplified later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Missed case regarding to time parsing]
with current time being 2024 and the only lesson is from 2000-2300 (ie including the current time),
when searching "avail 1700-2359 60", the result is "Available date is: 2022-11-06 2300-0000" which goes beyond the time range specified. This is regarding the incorrect handling of "0000" by endTimeFromClass
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved!
} else if (classToCompare.endTime.compareTo(tr.endTimeRange) < 0 | ||
&& classToCompare.startTime.compareTo(tr.startTimeRange) > 0) { | ||
if (currTime.compareTo(classToCompare.startTime) < 0) { | ||
if (endTimeFromTr.compareTo(classToCompare.startTime) <= 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comparison should be between endTimeFromCurrTime
and classToCompare.startTime
.
This will result the error when:
current time: 2040
only time 2100-2200
avail 2000-2300 10
will give Available date is: 2022-11-06 2000-2010
which is before the current time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved!
if (currTime.compareTo(classToCompare.startTime) < 0) { | ||
if (endTimeFromTr.compareTo(classToCompare.startTime) <= 0) { | ||
newClass = new Class(currDate, startTimeFromTr, endTimeFromTr); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Missed corner case]
when the current time is before the single class start time, the front part is checked but the part after the class is ignored.
Current time: 2052
Single lesson: 2100-2200
avail 2030-2359 60
expects to give 2022-11-06 2200-2300
but gives 2022-11-07 2030-2130
in reality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved!
…into fix-avail-command-bugs * 'master' of https://github.com/AY2223S1-CS2103T-T09-4/tp: (23 commits) Improve method naming and error message Improve grammar Minor update for NFR in DG Improve format for UG Fix undo not resetting bug Fix style issues Add more tests for mark Edit existing tests Remove displayedClass field from all main code Remove automated next class feature Remove displayedClass field from Student Fix checkstyle Update message Display error message Prevent saving of files if json is in invalid format Fix Compile Error by UndoCommandParser Fix checkstyle Add new line Update javadocs Update testing and add new json file ...
newClass = new Class(currDate, startTimeFromCurrTime, endTimeFromCurrTime); | ||
} | ||
} | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this else block is duplicative of the nullity check in line 644. Same applies to the else block in line 639.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved!
with current time being 2024 and the only lesson is from 2000-2300 (ie including the current time), when searching "avail 1700-2359 60", the result is "Available date is: 2022-11-06 2300-0000" which goes beyond the time range specified. This is regarding the incorrect handling of "0000" by endTimeFromClass
Bug is when current time: 2040 only time 2100-2200 avail 2000-2300 10 will give Available date is: 2022-11-06 2000-2010 which is before the current time.
} | ||
|
||
|
||
// Link to design for more than 2 classes: https://arc.net/e/8D5B34DF-70C5-4A22-8D26-4BFC6CEEABC5 | ||
for (int i = 0; i < list.size(); i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I am not done reading the code, so cannot really tell which part goes wrong. But I have found the bug here:
[Missed corner case]
current time: 0023
classes: [2022-11-07 0000-0100, 2022-11-07 0800-0900]
avail 0000-2300 100
expects 2022-11-07 0100-0240
but receives 2022-11-07 0023-0203
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I'll look into it. In the future, there is no need to try to find the bug for me. I can trace the code to try to solve the bug! Thank you so much for pointing it out in the past though!
Close #217 |
for (int i = 0; i < list.size(); i++) { | ||
Class aFirstClass = list.get(i).getAClass(); | ||
Class aFirstClass = list.get(i); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Missed corner case]
current time: 0045
classes: [2022-11-08 0000-0100, 2022-11-08 0400-0600]
avail 0000-0400 10
expects 2022-11-07 0045-0055
but receives 2022-11-08 0100-0110
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved!
[Missed corner case] current time: 0023 classes: [2022-11-07 0000-0100, 2022-11-07 0800-0900] avail 0000-2300 100 expects 2022-11-07 0100-0240 but receives 2022-11-07 0023-0203
[Missed corner case] current time: 0045 classes: [2022-11-08 0000-0100, 2022-11-08 0400-0600] avail 0000-0400 10 expects 2022-11-07 0045-0055 but receives 2022-11-08 0100-0110
for (int i = 0; i < list.size(); i++) { | ||
Class aFirstClass = list.get(i).getAClass(); | ||
Class aFirstClass = list.get(i); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Missed corner case]
current time: 0149
classes: [2022-11-08 0200-0300, 2022-11-08 0400-0500]
avail 0000-0400 15
expects 2022-11-07 0149-0204
but receives 2022-11-07 0000-0015
Add ability to get next available date from the current time
Closes #297 #259 #258 #257 #250 #243 #236
Initial bugs from original PR #198