Skip to content

fix(usage notifications): handle plans with billing terms longer than 12 months #5415

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

matthewelwell
Copy link
Contributor

Changes

This PR fixes an issue raised by a customer where they were sent a notification saying that they had used more than 500% of their allowance because the query to influx was returning all of their usage since the start of the billing period.

The bug was that relativedelta.months is not the same as relativedelta.total_months so actually the result from relativedelta.months was 0 rather than 12, because the relative delta looked something like relativedelta(years=1, months=0, ...).

I'm still unsure how we have billing terms that last for longer than 12 months, but this change should be robust to handle billing terms <12 months, or >12 months.

External (private) references for context:

Crisp chat with customer
Slack conversation

How did you test this code?

Added a new unit test.

@matthewelwell matthewelwell requested a review from a team as a code owner May 2, 2025 10:23
@matthewelwell matthewelwell requested review from gagantrivedi and removed request for a team May 2, 2025 10:23
Copy link

vercel bot commented May 2, 2025

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

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs ⬜️ Ignored (Inspect) May 2, 2025 10:24am
flagsmith-frontend-preview ⬜️ Ignored (Inspect) May 2, 2025 10:24am
flagsmith-frontend-staging ⬜️ Ignored (Inspect) May 2, 2025 10:24am

@github-actions github-actions bot added api Issue related to the REST API fix labels May 2, 2025
Copy link
Contributor

github-actions bot commented May 2, 2025

Docker builds report

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

Copy link
Contributor

github-actions bot commented May 2, 2025

Uffizzi Ephemeral Environment Deploying

☁️ https://app.uffizzi.com/github.com/Flagsmith/flagsmith/pull/5415

⚙️ Updating now by workflow run 14793448322.

What is Uffizzi? Learn more!

Copy link

codecov bot commented May 2, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.62%. Comparing base (d5b5e97) to head (9efdaad).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5415   +/-   ##
=======================================
  Coverage   97.62%   97.62%           
=======================================
  Files        1238     1238           
  Lines       43076    43088   +12     
=======================================
+ Hits        42053    42065   +12     
  Misses       1023     1023           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

2 participants