From 9c519d937da83a4f486203f54fd4678938143aa4 Mon Sep 17 00:00:00 2001 From: gitlawr Date: Fri, 22 May 2026 18:02:31 +0800 Subject: [PATCH] fix(usage): pass scope to the time series chart fetch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Usage page's chart fetch (``fetchTimeSeriesData``) spread ``chartFilters`` plus dates and filters, but never forwarded ``commonFilters.scope`` — so it implicitly fell back to the backend's ``scope=all`` default. The three breakdown tables (``apikeys-table``, ``models-table``, ``users-table``) all pass ``scope`` explicitly, which produced an inconsistent picture on the same page: an Org owner viewing a model granted from another Org saw the date chart render empty while the tables underneath showed identical usage rows. Forward ``currentSelectedFilters.scope`` alongside the rest of the common filters so the chart and the tables ask the backend the same question. --- src/pages/usage/hooks/use-usage-filters.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pages/usage/hooks/use-usage-filters.ts b/src/pages/usage/hooks/use-usage-filters.ts index 8d1a2bd3..5a0802d6 100644 --- a/src/pages/usage/hooks/use-usage-filters.ts +++ b/src/pages/usage/hooks/use-usage-filters.ts @@ -208,6 +208,12 @@ export const useUsageFilters = ({ fetchTimeSeriesData({ ...currentChartFilters, group_by: groupByArray, + // Without ``scope`` the backend defaults to ``all``, while the + // breakdown tables pass ``scope`` explicitly. The mismatch makes + // the chart and the tables run different filters on the same + // page — an Org owner viewing a cross-Org-granted model sees the + // chart empty while the tables render the same usage. + scope: currentSelectedFilters.scope, start_date: currentSelectedFilters.start_date, end_date: currentSelectedFilters.end_date, filters: nextFilters