Skip to content

[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

Merged
merged 1 commit into from
Sep 15, 2022
Merged

Conversation

svenefftinge
Copy link
Member

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

NONE

Documentation

Werft options:

  • /werft with-preview

@svenefftinge svenefftinge requested a review from a team September 15, 2022 11:47
@github-actions github-actions bot added the team: webapp Issue belongs to the WebApp team label Sep 15, 2022
const upcomingInvoice = await this.billingService.getUpcomingInvoice(attributionId);
const currentInvoiceCredits = upcomingInvoice.credits | 0;
const now = new Date();
const currentBalance = await this.usageService.listUsage({
Copy link
Member

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

Copy link
Member Author

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

Copy link
Member

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.

Copy link
Member Author

@svenefftinge svenefftinge Sep 15, 2022

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)

Copy link
Member Author

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.

Copy link
Member

@easyCZ easyCZ left a 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

@svenefftinge
Copy link
Member Author

/unhold

@roboquat roboquat merged commit c9aa527 into main Sep 15, 2022
@roboquat roboquat deleted the se/use-credit-balance branch September 15, 2022 11:57
@roboquat roboquat added deployed: webapp Meta team change is running in production deployed Change is completely running in production labels Sep 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployed: webapp Meta team change is running in production deployed Change is completely running in production release-note-none size/S team: webapp Issue belongs to the WebApp team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants