fix(ccusage): accept period key from current ccusage#2732
Open
mvanhorn wants to merge 1 commit into
Open
Conversation
Contributor
|
Automatic message from CI checks : It seems like this branch is targeting the wrong branch, any contribution should target develop branch. See CONTRIBUTING.md for details. |
Contributor
|
Automatic message from CI checks : It seems like this branch is targeting the wrong branch, any contribution should target develop branch. See CONTRIBUTING.md for details. |
ccusage renamed the per-record key from month/date/week to `period`, so the deserializer's required old field names no longer match and `rtk cc-economics` fails with "missing field `month`". Add `#[serde(alias = "period")]` to the daily/weekly/monthly key fields so both legacy and current ccusage output parse. Adds period-shape tests for all three granularities; existing legacy-key tests stay green.
07d1e0d to
d0a77cd
Compare
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
rtk cc-economicscurrently fails withmissing field month(serde: missing fieldmonth) because ccusage renamed its per-record key frommonth/date/weektoperiod. The deserializer insrc/analytics/ccusage.rsstill required the old names, so every record fails to parse and the feature is unusable.Changes
#[serde(alias = "period")]to the key field ofDailyEntry,WeeklyEntry, andMonthlyEntry. This accepts the currentperiodkey while staying backward-compatible with older ccusage output that still emitsmonth/date/week. No other behavior changes.Tests
cargo fmt --all,cargo clippy --all-targets, andcargo test --allall clean (2290 passed).cargo run -- cc-economicsnow renders against live ccusage with no parse error.Closes #2731