fix(usage): count whole years when resolving the current billing period - #8429
Closed
talissoncosta wants to merge 2 commits into
Closed
fix(usage): count whole years when resolving the current billing period#8429talissoncosta wants to merge 2 commits into
talissoncosta wants to merge 2 commits into
Conversation
The current period was derived from the months component of the delta between now and the billing term start, so whole years were dropped. A term that began more than twelve months ago resolved to a period a year early, and the usage page reported a window over a year long instead of the current month. The same arithmetic existed in three places and was correct in only one of them, so it now lives in one function used by all three: the usage data query, the API usage notifications view and the notification task. The view had the same bug, which meant a stale notification could be treated as current. Closes #6099 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8429 +/- ##
=======================================
Coverage 98.81% 98.81%
=======================================
Files 1621 1623 +2
Lines 66118 66145 +27
=======================================
+ Hits 65334 65361 +27
Misses 784 784 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
docs/if required so people know about the feature.Changes
Closes #6099.
The current billing period was derived from
relativedelta(now, starts_at).months, which drops whole years. A term that began more than twelve months ago resolved a year early, so the usage page reported a window over a year long against one month's allowance.The same arithmetic existed in three places and was right in only one. It now lives in
get_current_billing_period_start_dateand all three use it: the usage query, the API usage notifications view, and the notification task. The view had the same bug, so a stale notification could be treated as current.How did you test this code?
Unit tests for a term started 13 months ago, across the service, the usage query and the view.