fix(xiaomi): compute utilisation from used/limit, not truncated percent#3
Merged
Merged
Conversation
Xiaomi's console returns the convenience ``percent`` field truncated to an integer, so a real 3.68 % shows as 0 % on the badge and on the sentinel. Compute from ``used / limit`` whenever both are present and only fall back to ``percent`` when ``limit`` is missing. Regression test added; the existing ``monthly`` window assertion is relaxed to the now-more-precise value computed from used/limit.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Xiaomi console returns the convenience
percentfield truncated to an integer. A real 3.68 % comes back as0, so the badge and the sentinel show "0 %" on a plan that's actually 4 %-used.Compute utilisation from
used / limitwhenever both are present and only fall back topercentwhenlimitis missing.Test plan
pytest— 241 tests passtest_fetch_prefers_used_over_truncated_percent(404M/11B withpercent: 0→ 3.68 %)monthlywindow assertion updated to the now-more-precise value