fix(usage): use frontend gpu_type token for instance-type legend

flattenItem receives the unmapped frontend dimension; the instance-type
grouping is 'gpu_type' (mapped to backend 'instance_type' via GROUP_BY_MAP),
so the previous 'instance_type' check never matched and the trend legend kept
showing the raw flavor slug. Check 'gpu_type'. (PR #1240 review)
This commit is contained in:
michelia
2026-06-27 22:27:42 +08:00
committed by jialin
parent 1a6d1654b2
commit 8f85e9a082
+6 -4
View File
@@ -321,11 +321,13 @@ function flattenItem(
if (dims.storage_type) flat.storage_type = dims.storage_type;
if (dims.capacity_mib != null) flat.capacity_mib = dims.capacity_mib;
}
// For an instance_type grouped trend the series label (``group``) defaults to
// For an instance-type grouped trend the series label (``group``) defaults to
// the raw flavor slug; prefer the pretty product name so the chart legend
// matches the GPU Instances list (#5700). Falls back to the slug for legacy
// rows that predate dimension enrichment.
if (groupBy === 'instance_type' && flat.product) {
// matches the GPU Instances list (#5700). ``groupBy`` here is the unmapped
// frontend dimension — ``gpu_type`` maps to the backend's ``instance_type``
// (see GROUP_BY_MAP). Falls back to the slug for legacy rows that predate
// dimension enrichment.
if (groupBy === 'gpu_type' && flat.product) {
flat.group = flat.product;
}
return flat;