Rounding causes discrepancy between instance and runner visualization of minutes
Problem
Regarding the dedicated hosted runner visualization @gabrielengel_gl said:
It also appears that the number of the first graph doesn't quite add up with the numbers from the second graph. The first graph shows 26, the second graphs numbers add up to 24. Any ideas why that is?
| Description | Image |
|---|---|
| Instance level | ![]() |
| Runner level | ![]() |
Root Cause Analysis
It's because the api types are ints. That causes it to round down. When we round down for each namespace it creates a discrepancy from the total instance figure which is calculated based on the un-rounded numbers.
Proposal
Show the namespace usage to 2 decimal places.
Implementation of using floats
We need to use expand-contract here. Add a new api field with the float type. Then deprecate the old field so we don't break things.
diff --git a/ee/app/graphql/ee/types/ci/minutes/dedicated_monthly_usage_type.rb b/ee/app/graphql/ee/types/ci/minutes/dedicated_monthly_usage_type.rb
index ebbd7483235f8..889387291f599 100644
--- a/ee/app/graphql/ee/types/ci/minutes/dedicated_monthly_usage_type.rb
+++ b/ee/app/graphql/ee/types/ci/minutes/dedicated_monthly_usage_type.rb
@@ -19,10 +19,16 @@ class DedicatedMonthlyUsageType < ::Types::BaseObject
description: 'Timestamp of the billing month in ISO 8601 format.'
field :compute_minutes, GraphQL::Types::Int, null: false,
- description: 'Total compute minutes used across all namespaces.'
+ description: 'Total compute minutes used across all namespaces rounded.'
field :duration_seconds, GraphQL::Types::Int, null: false,
- description: 'Total duration in seconds of runner usage.'
+ description: 'Total duration in seconds of runner usage rounded.'
+
+ field :compute_minutes_usage, GraphQL::Types::Float, null: false,
+ description: 'Total compute minutes used across all namespaces (float).'
+
+ field :duration_minutes, GraphQL::Types::Float, null: false,
+ description: 'Total duration converted to minutes (float).'
field :root_namespace, ::Types::Ci::Minutes::NamespaceUnionType, null: true,
description: 'Namespace associated with the usage data. Null for instance aggregate data.'
Then we can switch the vue components on the frontend to use the new fields instead of the old one.

