-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[usage] use credit balance for limit check #12997
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
Conversation
const upcomingInvoice = await this.billingService.getUpcomingInvoice(attributionId); | ||
const currentInvoiceCredits = upcomingInvoice.credits | 0; | ||
const now = new Date(); | ||
const currentBalance = await this.usageService.listUsage({ |
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.
We could also specify Page Size 1 or 0 to avoid getting any results in the list response, we don't need it
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 use from: now, to: now
which does also make sure we don't fetch usage entries
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.
Fair. We could change the usage implementation that if page size is 0, we don't even make the (list) query in the first place which would then be a bit faster.
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'd rather introduce a new function. There's too much information in the response that wouldn't make sense (e.g. balanceAtStart vs balanceAtEnd)
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.
your proposal makes sense once we need balance for a period but are not interested in the entries.
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.
/hold if you want to set the page size
/unhold |
Description
For checking the usage limit, instead of checking against the current stripe invoice we want to check against the current credit balance.
Related Issue(s)
Fixes #
How to test
Release Notes
Documentation
Werft options: