Skip to content

fix(xiaomi): compute utilisation from used/limit, not truncated percent#3

Merged
millaguie merged 1 commit into
mainfrom
fix/xiaomi-percent-truncation
May 30, 2026
Merged

fix(xiaomi): compute utilisation from used/limit, not truncated percent#3
millaguie merged 1 commit into
mainfrom
fix/xiaomi-percent-truncation

Conversation

@millaguie

Copy link
Copy Markdown
Owner

Summary

The Xiaomi console returns the convenience percent field truncated to an integer. A real 3.68 % comes back as 0, so the badge and the sentinel show "0 %" on a plan that's actually 4 %-used.

Compute utilisation from used / limit whenever both are present and only fall back to percent when limit is missing.

Test plan

  • pytest — 241 tests pass
  • New regression test: test_fetch_prefers_used_over_truncated_percent (404M/11B with percent: 0 → 3.68 %)
  • Existing monthly window assertion updated to the now-more-precise value

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.
@millaguie millaguie merged commit 4e7601d into main May 30, 2026
3 checks passed
@millaguie millaguie deleted the fix/xiaomi-percent-truncation branch May 30, 2026 17:30
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