Repository navigation
Fix previous_months_iterator - #358
Merged
Merged
Conversation
bryanlandia
force-pushed
the
bryan/fix-prev-months-iterator
branch
3 times, most recently
from
June 8, 2021 23:52
225dfc6 to
d0c4b13
Compare
bryanlandia
marked this pull request as ready for review
June 9, 2021 00:05
Contributor
Author
|
Hi @johnbaldwin I've updated the helper method and associated test method. The previous_months_iterator is now working properly across short months, leap years, and returns the correct number of months back. |
Avoid rrule when possibly iterating forward from days 29-31 of months, rrule simply skip month if it tries to iterate to e.g., February 30. previous_months_iterator start num_months -1 back to incl. current Since changing the method of providing a previous months generator, we need to start one fewer months back or we lose the current month in the output. current_month should be last month returned in history
frontend code expects last entry in history to be current_month: for example, in code for current month change since last month, comparison is to `this.state.valueHistory.size-2` -1 since array is 0-indexed, -2 to find previous month val in history Probably the months_back 7 was being used in tests because of the issue that this PR addresses.
If month_for is June and months_back is 6, should return last day of June and 5 previous months--Jan, Feb, Mar, Apr, May, June Handle months_back of zero properly, returning the month_for month
bryanlandia
force-pushed
the
bryan/fix-prev-months-iterator
branch
from
June 10, 2021 01:31
d0c4b13 to
eaf2455
Compare
johnbaldwin
approved these changes
Jun 10, 2021
johnbaldwin
left a comment
Contributor
There was a problem hiding this comment.
@bryanlandia Looks reasonable to me. Thanks!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses #356
Avoid rrule when possibly iterating forward from days 29-31 of months,
rrule simply skip month if it tries to iterate to e.g., February 30.