Skip to content
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

End date shouldn't be included in month calculations #37

Open
mmallozzi opened this issue Jul 26, 2021 · 0 comments
Open

End date shouldn't be included in month calculations #37

mmallozzi opened this issue Jul 26, 2021 · 0 comments

Comments

@mmallozzi
Copy link

When the end date is on the first of a month (e.g. October 1st), a request is issued both for dates in September and October. However, the end date is documented to be exclusive for this script, as it's the checkout date. So an extra unneeded request is being issued, which given the sensitive rate limiting on recreation.gov, would add to the instability.

Cause:
An rrule monthly rule includes the end date by default, so get_park_information ends up fetching for both months.

Solution:
I believe this can be solved by excluding the end date using exdate. Something like this:

start_of_month = datetime(start_date.year, start_date.month, 1)
ruleset = rrule.rruleset()
ruleset.rrule(rrule.rrule(rrule.MONTHLY, dtstart=start_of_month, until=end_date))
# exclude end date as that is the checkout date
ruleset.exdate(end_date)
months = list(ruleset)

I haven't robustly tested this to ensure it doesn't break other scenarios, but seems to work for my use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant