fix(usage): fetch full trend/export series via page=-1
Trend charts and breakdown exports need the complete date series. The old perPage=10000 workaround (and the missing page param on the token trend, which fell back to perPage=20) dropped low-traffic — often most recent — buckets, leaving gaps in the charts (#5690). Send page=-1 (the backend's no-pagination sentinel) for the token trend, the storage/instances trend charts and table exports, the resource export dialog, and the summary-tab date trends.
This commit is contained in:
@@ -163,11 +163,12 @@ const ResourceExportData: React.FC<ResourceExportDataProps> = (props) => {
|
|||||||
setPageParams({ page, perPage });
|
setPageParams({ page, perPage });
|
||||||
};
|
};
|
||||||
|
|
||||||
// Export the full filtered set, not just the visible page.
|
// Export the full filtered set, not just the visible page. ``page: -1`` is
|
||||||
|
// the backend's no-pagination sentinel (perPage is then ignored).
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
setExporting(true);
|
setExporting(true);
|
||||||
try {
|
try {
|
||||||
const res = await queryFn(buildRequest(1, 10000));
|
const res = await queryFn(buildRequest(-1, INITIAL_PAGE.perPage));
|
||||||
exportBreakdownRows(
|
exportBreakdownRows(
|
||||||
res.items ?? [],
|
res.items ?? [],
|
||||||
toExportColumns(columns),
|
toExportColumns(columns),
|
||||||
|
|||||||
@@ -208,6 +208,11 @@ export const useUsageFilters = ({
|
|||||||
fetchTimeSeriesData({
|
fetchTimeSeriesData({
|
||||||
...currentChartFilters,
|
...currentChartFilters,
|
||||||
group_by: groupByArray,
|
group_by: groupByArray,
|
||||||
|
// The trend chart needs the complete date series. ``page: -1`` is the
|
||||||
|
// backend's no-pagination sentinel — without it the default page (20
|
||||||
|
// buckets, sorted by total tokens) drops low-traffic dates, leaving
|
||||||
|
// gaps in the chart for ranges spanning more than a handful of buckets.
|
||||||
|
page: -1,
|
||||||
// Without ``scope`` the backend defaults to ``all``, while the
|
// Without ``scope`` the backend defaults to ``all``, while the
|
||||||
// breakdown tables pass ``scope`` explicitly. The mismatch makes
|
// breakdown tables pass ``scope`` explicitly. The mismatch makes
|
||||||
// the chart and the tables run different filters on the same
|
// the chart and the tables run different filters on the same
|
||||||
|
|||||||
@@ -148,7 +148,8 @@ const GpuInstancesTab: React.FC = () => {
|
|||||||
// whole range. The default order is metric-desc, so partial (current/
|
// whole range. The default order is metric-desc, so partial (current/
|
||||||
// recent) buckets have smaller values and would be pushed onto later
|
// recent) buckets have smaller values and would be pushed onto later
|
||||||
// pages — dropping the newest hours from the chart under a small page.
|
// pages — dropping the newest hours from the chart under a small page.
|
||||||
perPage: 10000
|
// ``page: -1`` is the backend's no-pagination sentinel.
|
||||||
|
page: -1
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -296,7 +297,8 @@ const GpuInstancesTab: React.FC = () => {
|
|||||||
...baseRequest(),
|
...baseRequest(),
|
||||||
group_by: [g.key],
|
group_by: [g.key],
|
||||||
// A breakdown export is the full filtered set, not a page.
|
// A breakdown export is the full filtered set, not a page.
|
||||||
perPage: 10000
|
// ``page: -1`` is the backend's no-pagination sentinel.
|
||||||
|
page: -1
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -140,7 +140,8 @@ const StorageTab: React.FC = () => {
|
|||||||
// whole range. The default order is metric-desc, so partial (current/
|
// whole range. The default order is metric-desc, so partial (current/
|
||||||
// recent) buckets have smaller values and would be pushed onto later
|
// recent) buckets have smaller values and would be pushed onto later
|
||||||
// pages — dropping the newest hours from the chart under a small page.
|
// pages — dropping the newest hours from the chart under a small page.
|
||||||
perPage: 10000
|
// ``page: -1`` is the backend's no-pagination sentinel.
|
||||||
|
page: -1
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -283,7 +284,8 @@ const StorageTab: React.FC = () => {
|
|||||||
...baseRequest(),
|
...baseRequest(),
|
||||||
group_by: [g.key],
|
group_by: [g.key],
|
||||||
// A breakdown export is the full filtered set, not a page.
|
// A breakdown export is the full filtered set, not a page.
|
||||||
perPage: 10000
|
// ``page: -1`` is the backend's no-pagination sentinel.
|
||||||
|
page: -1
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -299,16 +299,21 @@ const SummaryTab: React.FC = () => {
|
|||||||
filters: creatorFilter
|
filters: creatorFilter
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
// Date-bucketed trends: fetch the whole series via the no-pagination
|
||||||
|
// sentinel (page: -1). A metric-desc page would drop low-traffic (often
|
||||||
|
// most recent) buckets and leave gaps in the chart.
|
||||||
fetchTokenSeries({
|
fetchTokenSeries({
|
||||||
...commonParams,
|
...commonParams,
|
||||||
metric: 'total_tokens',
|
metric: 'total_tokens',
|
||||||
group_by: ['date'],
|
group_by: ['date'],
|
||||||
granularity,
|
granularity,
|
||||||
|
page: -1,
|
||||||
filters: {}
|
filters: {}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
fetchComputeBreakdown({
|
fetchComputeBreakdown({
|
||||||
...paginationParams,
|
...paginationParams,
|
||||||
|
page: -1,
|
||||||
group_by: ['date'],
|
group_by: ['date'],
|
||||||
granularity,
|
granularity,
|
||||||
filters: creatorFilter
|
filters: creatorFilter
|
||||||
@@ -316,6 +321,7 @@ const SummaryTab: React.FC = () => {
|
|||||||
|
|
||||||
fetchStorageByDate({
|
fetchStorageByDate({
|
||||||
...paginationParams,
|
...paginationParams,
|
||||||
|
page: -1,
|
||||||
group_by: ['date'],
|
group_by: ['date'],
|
||||||
granularity,
|
granularity,
|
||||||
filters: creatorFilter
|
filters: creatorFilter
|
||||||
|
|||||||
Reference in New Issue
Block a user