Skip to content

Fix zero usage percentages in org plan usage#1783

Merged
riderx merged 2 commits into
mainfrom
riderx/fix-plan-usage-percent
Mar 12, 2026
Merged

Fix zero usage percentages in org plan usage#1783
riderx merged 2 commits into
mainfrom
riderx/fix-plan-usage-percent

Conversation

@riderx
Copy link
Copy Markdown
Member

@riderx riderx commented Mar 12, 2026

Summary

  • Fixed organization usage cards to derive MAU, bandwidth, storage, and build-time percentages from live usage data when the get_plan_usage_percent_detailed payload incorrectly returns all-zero percentages while usage exists.
  • Kept all original backend values when at least one percentage is non-zero, so the fallback only applies to the all-zero edge case.
  • Added a safe percentage helper and updated storage handling to retain raw byte totals for accurate fallback calculations.

Test plan

  • Ran bun lint src/pages/settings/organization/Usage.vue.
  • Loaded an organization usage page with known non-zero MAU/bandwidth/storage/build time and verified category percentages no longer show 0% for every category.

Screenshots

  • Not added (logic-only UI calculation update).

Checklist

  • My code follows the code style of this project and passes bun run lint:backend && bun run lint.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • My change has adequate E2E test coverage.
  • I have tested my code manually, and I have provided steps how to reproduce my tests

Summary by CodeRabbit

  • New Features
    • UI now derives missing per-category usage percentages when detailed percentages are absent, ensuring more complete usage breakdowns.
  • Bug Fixes
    • Improved accuracy of usage percentage calculations for storage, bandwidth, monthly active users, and build time.
    • Enhanced retrieval and conversion of total storage for more reliable reporting.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 12, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6be18354-dd85-497b-8535-16a8daed8d55

📥 Commits

Reviewing files that changed from the base of the PR and between a69a0d5 and 15d98b4.

📒 Files selected for processing (1)
  • src/pages/settings/organization/Usage.vue

📝 Walkthrough

Walkthrough

Refactors organization usage logic: storage is fetched in bytes then converted to GB; adds percent() helper and maybeDeriveMissingUsagePercents() to infer missing per-category usage percentages from total usage before pricing/UI presentation.

Changes

Cohort / File(s) Summary
Usage Metrics Derivation
src/pages/settings/organization/Usage.vue
Added percent() utility and maybeDeriveMissingUsagePercents() to derive missing detailed usage percentages from total MAU, bandwidth, storage, and build time. Changed storage retrieval to use getTotalStorage(orgId)totalStorageBytes then convert to GB. Updated usage flow to call derivation with all totals prior to pricing calculations and UI data assembly.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 I nibble bytes and turn them bright,
From bytes to gigs I hop to light,
Percentages found where gaps once lay,
I stitch the counts and show the way,
A tidy trail of usage play. 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: fixing zero usage percentages in organization plan usage cards.
Description check ✅ Passed The description covers all required sections with clear explanations of the fix, test plan, and checklist, though checklist items are not marked complete.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch riderx/fix-plan-usage-percent
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/pages/settings/organization/Usage.vue`:
- Around line 144-150: The fallback inputs to maybeDeriveMissingUsagePercents
are passing totalBandwidthBytes and totalStorageBytes as raw bytes while
currentPlan.bandwidth and currentPlan.storage are interpreted as GB elsewhere;
convert the byte totals to GB before calling maybeDeriveMissingUsagePercents
(e.g., totalBandwidthGB = totalBandwidthBytes / (1024**3) and totalStorageGB =
totalStorageBytes / (1024**3)) so the derived percentages use matching units;
update both call sites that pass totalBandwidthBytes/totalStorageBytes (the
detailPlanUsage call and the similar call around the 253–255 region) to pass the
GB-converted values.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 70436eae-4727-44a4-a156-1fdc381bcbf4

📥 Commits

Reviewing files that changed from the base of the PR and between 22020f6 and a69a0d5.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (1)
  • src/pages/settings/organization/Usage.vue

Comment thread src/pages/settings/organization/Usage.vue Outdated
@riderx riderx force-pushed the riderx/fix-plan-usage-percent branch from a69a0d5 to 9e8b013 Compare March 12, 2026 20:10
@sonarqubecloud
Copy link
Copy Markdown

@riderx riderx merged commit 802b477 into main Mar 12, 2026
15 checks passed
@riderx riderx deleted the riderx/fix-plan-usage-percent branch March 12, 2026 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant