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

Avoid excess calls to get-subscription-metadata #2950

Closed
khvn26 opened this issue Nov 9, 2023 · 4 comments · Fixed by #2985
Closed

Avoid excess calls to get-subscription-metadata #2950

khvn26 opened this issue Nov 9, 2023 · 4 comments · Fixed by #2985
Assignees
Labels
api Issue related to the REST API

Comments

@khvn26
Copy link
Member

khvn26 commented Nov 9, 2023

We observed a rapid increase to call count for /api/v1/organisations/{pk}/get-subscription-metadata/:

image

Majority of those result in 404s and 403s:

image

We need to think of a way to rework the logic to minimize those calls.

@khvn26 khvn26 added the api Issue related to the REST API label Nov 9, 2023
@novakzaballa
Copy link
Contributor

@matthewelwell I would propose returning a non-error response from the BE when the user organization hasn't a subscription, we could instead return a 200 response with a body like {"subscription": null} in that case and otherwise can return:

{
  "subscription": {
    "max_seats": 0,
    "max_api_calls": 0,
    "max_projects": 0,
    "payment_source": null,
    "chargebee_email": "[email protected]"
  }
}

@matthewelwell
Copy link
Contributor

Looking at the code in OrganisationViewSet.get_subscription_metadata I'm not too sure why we're doing the organisation.has_subscription() check since all organisations should have a subscription (I've just checked production data and there are a few exceptions to this, all created on the 27th February this year) and Subscription.get_subscription_metadata() will handle the free plan data.

My suggestion would be to just remove that check and we'll fix the data for those organisations (possibly as part of a migration in the PR to fix this issue too).

@novakzaballa
Copy link
Contributor

I haven't worked directly on that part of the BE code, but in my experience, the endpoint is returning 404 for all free subscription orgs, and that's the case for my own free subscription org, created after I joined the company in April:
image

@matthewelwell
Copy link
Contributor

Sorry, yep, I was adding that comment for context as @zachaysan is going to start working on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issue related to the REST API
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants