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

fix: Set organisation api usage to zero #4611

Merged
merged 2 commits into from
Sep 26, 2024

Conversation

zachaysan
Copy link
Contributor

Changes

The original code involved in setting api_calls_24h, api_calls_7d, and api_calls_30d for the OrganisationSubscriptionInformationCache only updated values that were known to InfluxDB, this led to an issue where once an organisation left Flagsmith the code updating the values for 0 level API responses were instead left their previous value. This PR fixes that by checking for organisations that have no values and sets them to 0.

How did you test this code?

Partially manually against production InfluxDB and then added a test for the empty caches case.

@zachaysan zachaysan requested a review from a team as a code owner September 10, 2024 13:31
@zachaysan zachaysan requested review from gagantrivedi and removed request for a team September 10, 2024 13:31
Copy link

vercel bot commented Sep 10, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs ⬜️ Ignored (Inspect) Sep 10, 2024 1:31pm
flagsmith-frontend-preview ⬜️ Ignored (Inspect) Sep 10, 2024 1:31pm
flagsmith-frontend-staging ⬜️ Ignored (Inspect) Sep 10, 2024 1:31pm

@github-actions github-actions bot added api Issue related to the REST API fix labels Sep 10, 2024
Copy link
Contributor

github-actions bot commented Sep 10, 2024

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-api-test:pr-4611 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-e2e:pr-4611 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-frontend:pr-4611 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-api:pr-4611 Finished ✅ Results
ghcr.io/flagsmith/flagsmith:pr-4611 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-private-cloud:pr-4611 Finished ✅ Results

Copy link
Contributor

github-actions bot commented Sep 10, 2024

Uffizzi Preview deployment-56093 was deleted.

Copy link

codecov bot commented Sep 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.17%. Comparing base (1b22cf5) to head (d909f12).
Report is 29 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4611   +/-   ##
=======================================
  Coverage   97.16%   97.17%           
=======================================
  Files        1160     1160           
  Lines       40137    40181   +44     
=======================================
+ Hits        39000    39045   +45     
+ Misses       1137     1136    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@gagantrivedi
Copy link
Member

What if Postgres is being used to store usage data instead of influx?

@zachaysan
Copy link
Contributor Author

What if Postgres is being used to store usage data instead of influx?

Presently the update_caches function does not handle that use-case. The caches that are generated are mostly used for areas of the application which don't really have any use outside of the Flagsmith staff. For example, the sales dashboard is one of the uses of the cache.

That said, if we want to support the Postgres way of going about things then I'd argue we should create a new GitHub issue instead of lumping it in with this PR.

@matthewelwell matthewelwell added this pull request to the merge queue Sep 26, 2024
Merged via the queue into main with commit 008998c Sep 26, 2024
35 checks passed
@matthewelwell matthewelwell deleted the fix/set_organisation_api_usage_to_zero branch September 26, 2024 10:20
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 fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants