-
Notifications
You must be signed in to change notification settings - Fork 16
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
Refactor loading chronologically last passed schedule #7
base: main
Are you sure you want to change the base?
Refactor loading chronologically last passed schedule #7
Conversation
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'm all for reducing the number of lines in the code but I don't like to modify the list inside the if condition check. How about
schedules.add(schedule);
if (schedule.start.before(now))
schedules.removeIf(s -> s.start.before(schedule.start)))
I think it should have the same effect but intention is clear.
It won't work for:
all 3 playlists are started (including both past playlists). We could split my condition into 2 different |
@rogerlittin does the following look better to you?
|
That's really just replacing one large block of code with another large block. The original PR is probably cleaner. I won't be able to merge it for at least a week so if you come up with a better solution in the meantime please update here. |
Another idea: always keep the last past schedule at index 0:
|
Tested playlists:
result (logs):
result (logs):
result (logs):
result (logs):