fix(usage notifications): handle plans with billing terms longer than 12 months #5415
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.
Changes
This PR fixes an issue raised by a customer where they were sent a notification saying that they had used more than 500% of their allowance because the query to influx was returning all of their usage since the start of the billing period.
The bug was that
relativedelta.months
is not the same asrelativedelta.total_months
so actually the result fromrelativedelta.months
was 0 rather than 12, because the relative delta looked something likerelativedelta(years=1, months=0, ...)
.I'm still unsure how we have billing terms that last for longer than 12 months, but this change should be robust to handle billing terms <12 months, or >12 months.
External (private) references for context:
Crisp chat with customer
Slack conversation
How did you test this code?
Added a new unit test.