Conversation
- Updated UsageItem test fixtures to use GrossQuantity, NetQuantity, and DiscountQuantity fields instead of Quantity - Added cost assertions (GrossAmount, DiscountAmount, NetAmount) to test aggregation functions validate both quantities and costs - Added tolerance-based floating point comparison for NetAmount to prevent precision-related test failures - Enhanced test coverage to verify separate tracking of gross, net, and discount values for actions, packages, and storage
- Enhanced BillingUsageResponse with TimePeriod metadata fields - Renamed UsageItem.Quantity to GrossQuantity for API accuracy - Added NetQuantity and DiscountQuantity fields to UsageItem - Added cost fields (GrossAmount, DiscountAmount, NetAmount) to ActionsBilling, PackagesBilling, and StorageBilling structs - Updated StorageBilling with granular cost tracking per product - Added custom MarshalJSON to prevent scientific notation in JSON - Fixed aggregation functions to use gross/net/discount quantities - Updated aggregateStorageUsage to support Git LFS and Shared Storage products - Improved error handling for 403, 404, 422, 500, 502, 503 codes - Changed endpoint from usage to usage/summary for unified API - Fixed buildBillingQueryParams to use month/year not month-only - Updated display logic to show NetAmount instead of field names that previously mixed quantities with costs
- Added SetIndent with 2-space indentation for readable JSON output - Disabled HTML escaping via SetEscapeHTML(false) for cleaner JSON - Enhanced error handling to wrap and return encoding errors - Changed return from 'return err' to 'return nil' on success to avoid returning uninitialized error variable
- Added Output Fields section explaining each billing report type - Documented actions fields: minutes used, net cost, discount amount - Documented packages fields: bandwidth used, net cost, discount - Documented storage fields: total storage, actions/packages split, net cost with clarification on gigabyte-hours unit - Documented advanced security field: active committers count - Added Notes section distinguishing quantity vs cost fields - Noted JSON uses fixed precision to avoid scientific notation - Clarified storage includes Actions, Packages, and Git LFS data - Fixed SEE ALSO section formatting from bullet to dash list
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
Changes
Core Improvements (
cmd/billing.go)TimePeriod, renamedQuantity→GrossQuantity/NetQuantity/DiscountQuantityto match API exactlyGrossAmount,DiscountAmount,NetAmount) toActionsBilling,PackagesBilling, andStorageBillingstructsMarshalJSONforBillingReportJSONto prevent scientific notation (e.g.,0.0000000450instead of1.35e-7)/usageto/usage/summaryfor unified billing platformTesting (
cmd/billing_test.go)GrossQuantity,NetQuantity, etc.)JSON Utilities (
internal/utils/json.go)Documentation (
docs/report_billing.md)--show-costs)Testing
Impact
Before: Field names like
TotalPaidMinutesUsedmisleadingly stored dollar amounts instead of minutes, making code difficult to reason about.After: Clear separation with quantity fields (minutes/GB/GB-hours) and cost fields (USD), properly matching the GitHub API structure.
This is a non-breaking change for end users as CSV/table output format remains the same. JSON structure is enhanced with additional cost breakdown fields when using
--show-costs.