fix: resolve provider data output issues#12
Merged
Conversation
The 'Used / Remaining' format was showing 'used / remaining' but users expected 'remaining / total'. Changed formatUsedOfRemaining to prefer 'remaining / total' when total is available, with fallback to 'used / remaining' when total is not provided.
1. Fix Xiaomi API empty accountId - pass account to fetchApiBalance 2. Fix PERCENTAGE_REMAINING showing raw dollar amount - return -- when percentage cannot be calculated 3. Fix PERCENTAGE_REMAINING with zero values - show '0% remaining' instead of '/bin/zsh' 4. Fix REMAINING_ONLY DESCRIPTIVE for used-only data - show 'used this period' instead of 'used' 5. Update USED_OF_REMAINING description to match implementation - 'Remaining / Total' 6. Add tests for edge cases
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.
What
Fixes several issues with provider data output formatting and edge cases.
Why
Multiple providers had incorrect or inconsistent output formats for different balance display options.
Changes
Bug Fixes
Xiaomi API empty accountId -
fetchApiBalancewas settingaccountId = ""instead ofaccount.id. Fixed by passingaccountto the method.PERCENTAGE_REMAINING shows raw dollar amount - When only
remainingwas available (no total, no used), the format showed$55instead of--. Fixed to return--when percentage cannot be calculated.PERCENTAGE_REMAINING with zero values - When
remaining=0, used=0, showed$0instead of0% remaining. Fixed to handle zero case properly.REMAINING_ONLY DESCRIPTIVE for used-only data - DESCRIPTIVE format was identical to COMPACT when only
usedwas available. Fixed to show "$50 used this period" for DESCRIPTIVE.USED_OF_REMAINING description mismatch - Description said "Used / Remaining" but implementation shows "Remaining / Total". Updated description to match.
Tests Added
formats PERCENTAGE_REMAINING with zero remaining and used- Tests zero caseformats PERCENTAGE_REMAINING with only remaining falls back to remaining only- Tests fallback behaviorformats REMAINING_ONLY DESCRIPTIVE with only used- Tests DESCRIPTIVE formatFiles Modified
src/main/kotlin/org/zhavoronkov/tokenpulse/provider/xiaomi/XiaomiProviderClient.ktsrc/main/kotlin/org/zhavoronkov/tokenpulse/ui/BalanceFormatter.ktsrc/main/kotlin/org/zhavoronkov/tokenpulse/settings/TokenPulseSettings.ktsrc/test/kotlin/org/zhavoronkov/tokenpulse/ui/BalanceFormatterTest.ktVerification