fix(usage): unique filter option values so same-named entries don't co-select

This commit is contained in:
jialin
2026-07-09 20:36:52 +08:00
committed by jialin
parent 0d5812ba88
commit 4f4b527014
3 changed files with 21 additions and 25 deletions
+5 -3
View File
@@ -137,12 +137,14 @@ export function groupToOptions<T, TChild>(
options: {
getGroupKey: (item: T) => string;
getGroupType: (item: T) => string;
getChild: (item: T) => TChild;
// ``index`` is a stable per-row token so ``getChild`` can mint a unique
// option value for id-less (deleted) entries that share a display name.
getChild: (item: T, index: number) => TChild;
}
): GroupOption<TChild>[] {
const groupedMap = new Map<string, GroupOption<TChild>>();
data.forEach((item) => {
data.forEach((item, index) => {
const groupKey = options.getGroupKey(item);
const groupType = options.getGroupType(item);
@@ -156,7 +158,7 @@ export function groupToOptions<T, TChild>(
});
}
const child = options.getChild(item) as TChild & { value: string };
const child = options.getChild(item, index) as TChild & { value: string };
groupedMap.get(groupKey)!.children.push(child);
});
-4
View File
@@ -2,7 +2,6 @@ export interface UsageFilterItem {
identity: {
value: {
cluster_name: string;
model_name: string | null;
user_name: string;
api_key_name: string | null;
access_key: string | null;
@@ -12,7 +11,6 @@ export interface UsageFilterItem {
route_name: string | null;
};
current: {
model_id: string | null;
user_id: number | null;
api_key_id: string | null;
route_id: number | null;
@@ -49,7 +47,6 @@ export interface TimeSeriesData {
export type BreakdownItem = {
cluster_name: string;
model_name: string;
user_name: string;
api_key_name: string;
input_tokens: number;
@@ -88,7 +85,6 @@ export interface UsageBreakdownResponse {
export interface UsageMeta {
filters: {
models: UsageFilterItem[];
users: UsageFilterItem[];
api_keys: UsageFilterItem[];
routes: UsageFilterItem[];