mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-14 04:16:06 +00:00
fix(ui): use llm_call_count for provider/model distribution charts
Provider and Model donut charts showed 0 because they used request_count, which is only populated on channel-level snapshot rows. LLM-level rows store counts in llm_call_count instead.
This commit is contained in:
1 parent
eefc5ef4f2
commit
d6f83afda5
2 files changed
+7
-3
No files matched your search
@@ -17,6 +17,7 @@ interface DistributionDonutProps {
|
||||
loading?: boolean;
|
||||
activeValue?: string;
|
||||
onSliceClick?: (dimension: string) => void;
|
||||
metric?: "request_count" | "llm_call_count";
|
||||
}
|
||||
|
||||
interface SliceEntry {
|
||||
@@ -31,18 +32,19 @@ export function DistributionDonut({
|
||||
loading,
|
||||
activeValue,
|
||||
onSliceClick,
|
||||
metric = "request_count",
|
||||
}: DistributionDonutProps) {
|
||||
const { t } = useTranslation("usage");
|
||||
const isEmpty = !loading && data.length === 0;
|
||||
|
||||
const sorted = [...data].sort((a, b) => b.request_count - a.request_count);
|
||||
const sorted = [...data].sort((a, b) => b[metric] - a[metric]);
|
||||
const top = sorted.slice(0, MAX_SLICES);
|
||||
const rest = sorted.slice(MAX_SLICES);
|
||||
|
||||
const slices: SliceEntry[] = top.map((d) => ({ name: d.key, value: d.request_count, calls: d.request_count }));
|
||||
const slices: SliceEntry[] = top.map((d) => ({ name: d.key, value: d[metric], calls: d[metric] }));
|
||||
|
||||
if (rest.length > 0) {
|
||||
const otherCount = rest.reduce((sum, d) => sum + d.request_count, 0);
|
||||
const otherCount = rest.reduce((sum, d) => sum + d[metric], 0);
|
||||
slices.push({ name: t("analytics.distribution.other"), value: otherCount, calls: otherCount });
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ export function DistributionRow({
|
||||
loading={loading}
|
||||
activeValue={filters.provider}
|
||||
onSliceClick={(dim) => toggleFilter("provider", dim)}
|
||||
metric="llm_call_count"
|
||||
/>
|
||||
<DistributionDonut
|
||||
title={t("analytics.distribution.model")}
|
||||
@@ -34,6 +35,7 @@ export function DistributionRow({
|
||||
loading={loading}
|
||||
activeValue={filters.model}
|
||||
onSliceClick={(dim) => toggleFilter("model", dim)}
|
||||
metric="llm_call_count"
|
||||
/>
|
||||
<DistributionDonut
|
||||
title={t("analytics.distribution.channel")}
|
||||
|
||||
Reference in new issue
Block a user