-
Notifications
You must be signed in to change notification settings - Fork 30
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
Excludes times when they fall out of range #241
Conversation
|> Schedule.add_exception_time(~N[2017-09-09 13:00:00]) | ||
|> Schedule.add_exception_time(~N[2017-09-09 13:00:00]) | ||
|> Schedule.add_exception_time(~N[2017-09-09 13:30:00]) | ||
|> Schedule.add_exception_time(~N[2017-09-09 17:00:00]) | ||
|> Schedule.add_exception_time(~N[2017-09-10 10:00:00]) |
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.
There are no occurrences for 5 pm, so there's no reason to add an exception time for it. Also, we can remove the duplicated 1 pm exception time with no impact on the test assertions.
|> Schedule.add_exception_time(~N[2017-09-09 13:00:00]) | |
|> Schedule.add_exception_time(~N[2017-09-09 13:00:00]) | |
|> Schedule.add_exception_time(~N[2017-09-09 13:30:00]) | |
|> Schedule.add_exception_time(~N[2017-09-09 17:00:00]) | |
|> Schedule.add_exception_time(~N[2017-09-10 10:00:00]) | |
|> Schedule.add_exception_time(~N[2017-09-09 13:00:00]) | |
|> Schedule.add_exception_time(~N[2017-09-09 13:30:00]) | |
|> Schedule.add_exception_time(~N[2017-09-10 10:00:00]) |
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.
There are no occurrences for 5 pm, so there's no reason to add an exception time for it
I think there is a valid reason to test for this. I was playing the the idea of having an availability calendar that allowed users to book certain appointments.
Users have booking hours that they can be booked. We will state that users can book hours m-f 09:00 - 12:00 and 13:00 - 17:00. The user also has a vacation on a specific thursday and friday.
You could handle this by iterating over each time segment to see if a date falls within the time off and exclude those. Or you could add exceptions for the times in between those hours even if they are not in the schedule.
However, if you feel this does not coincide with the way the library should function I'll be happy to take the suggestion. Playing devils advocate a bit, I think there is a valid reason to have exceptions even if there are not time segments that fulfill those exceptions.
Also, we can remove the duplicated 1 pm exception time with no impact on the test assertions.
Good point. This test was written in true TDD style. If you run this test currently the double 13:00:00 will break the current implementation. 13:00:00 will still show up in the schedule even though there is an exception.
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.
Got it, as I said, those are minor points, and now that you explained the reasons for it, I'm totally good with it!
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.
LGTM, only a few minor comments.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #241 +/- ##
==========================================
+ Coverage 96.57% 96.59% +0.02%
==========================================
Files 21 21
Lines 496 499 +3
==========================================
+ Hits 479 482 +3
Misses 17 17 ☔ View full report in Codecov by Sentry. |
Co-authored-by: Luiz Augusto dos Reis Miranda <[email protected]>
Currently there seems to be a bug when you have exceptions that fall out of range of the schedule.
Example:
Results in:
The expectation is
%Cocktail.Span{from: ~N[2017-09-10 10:00:00], until: ~N[2017-09-10 10:30:00]}
and%Cocktail.Span{from: ~N[2017-09-09 13:00:00], until: ~N[2017-09-09 13:30:00]}
should not show up.