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

refactor: add functions to estimate monthly usage from data directly #9219

Merged
merged 9 commits into from
Feb 5, 2025

Conversation

thomasheartman
Copy link
Contributor

@thomasheartman thomasheartman commented Feb 5, 2025

Adds new monthly estimation functions that operate on raw usage data instead of chart data. This brings those methods in line with the rest of the traffic calculation functions that we have in that file and means we can remove other external dependencies.

This is somewhat inspired by #9218, but not directly linked.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Copy link

vercel bot commented Feb 5, 2025

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

Name Status Preview Comments Updated (UTC)
unleash-monorepo-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 5, 2025 9:16am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
unleash-docs ⬜️ Ignored (Inspect) Visit Preview Feb 5, 2025 9:16am

Copy link
Contributor

github-actions bot commented Feb 5, 2025

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Files

? chartDataSelection.month
: currentMonth,
data.datasets,
traffic.usage?.apiData,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ? is because usage might be undefined. This is because the hook doesn't account for whether you have data or not. I'll address this in (yet another) followup.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was an incidental refactoring. We now filter the data before it goes into the component, so we can drop it here. Additionally, we have the current month defined elsewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is moving the old functions back to where they were originally defined. Because we no longer want them in traffic-calculations, we might as well put them back so we remember to delete them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes here are all about testing the new implementations against the old one. Given the same data in, they should get the same result out.

@thomasheartman thomasheartman merged commit 17a4099 into main Feb 5, 2025
7 of 11 checks passed
@thomasheartman thomasheartman deleted the refactor/calculate-estimated-usage-from-data branch February 5, 2025 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants