diff --git a/autogpt_platform/backend/backend/data/platform_cost.py b/autogpt_platform/backend/backend/data/platform_cost.py index 4517864d20..226b6eae80 100644 --- a/autogpt_platform/backend/backend/data/platform_cost.py +++ b/autogpt_platform/backend/backend/data/platform_cost.py @@ -352,8 +352,11 @@ async def get_platform_cost_dashboard( # Build parameterised WHERE clause for the raw SQL percentile/bucket # queries. Uses _build_raw_where so filter logic is shared with # _build_prisma_where and only maintained in one place. + # Always force tracking_type=None here so _build_raw_where defaults to + # "cost_usd" — percentile and histogram queries only make sense on + # cost-denominated rows, regardless of what the caller is filtering. raw_where, raw_params = _build_raw_where( - start, end, provider, user_id, model, block_name, tracking_type + start, end, provider, user_id, model, block_name, tracking_type=None ) # Queries that always run regardless of tracking_type filter. diff --git a/autogpt_platform/frontend/src/app/(platform)/admin/platform-costs/__tests__/PlatformCostContent.test.tsx b/autogpt_platform/frontend/src/app/(platform)/admin/platform-costs/__tests__/PlatformCostContent.test.tsx index 317cb5c240..bde8507b37 100644 --- a/autogpt_platform/frontend/src/app/(platform)/admin/platform-costs/__tests__/PlatformCostContent.test.tsx +++ b/autogpt_platform/frontend/src/app/(platform)/admin/platform-costs/__tests__/PlatformCostContent.test.tsx @@ -185,7 +185,9 @@ describe("PlatformCostContent", () => { ); expect(screen.getByText("$5.0000")).toBeDefined(); expect(screen.getByText("100")).toBeDefined(); - expect(screen.getByText("5")).toBeDefined(); + // "5" appears in multiple places (Active Users card + bucket count), + // so verify at least one element renders it. + expect(screen.getAllByText("5").length).toBeGreaterThanOrEqual(1); expect(screen.getByText("openai")).toBeDefined(); expect(screen.getByText("google_maps")).toBeDefined(); }); diff --git a/autogpt_platform/frontend/src/app/(platform)/admin/platform-costs/components/PlatformCostContent.tsx b/autogpt_platform/frontend/src/app/(platform)/admin/platform-costs/components/PlatformCostContent.tsx index 9e94f7617c..9e9409ee36 100644 --- a/autogpt_platform/frontend/src/app/(platform)/admin/platform-costs/components/PlatformCostContent.tsx +++ b/autogpt_platform/frontend/src/app/(platform)/admin/platform-costs/components/PlatformCostContent.tsx @@ -264,8 +264,7 @@ export function PlatformCostContent({ searchParams }: Props) { value: Math.round( dashboard.avg_output_tokens_per_request ?? 0, ).toLocaleString(), - subtitle: - "Completion tokens per request (response length)", + subtitle: "Completion tokens per request (response length)", }, { label: "Total Tokens",