fix(usage): carry full filter set in breakdown tables and fix double fetch

- breakdown sub-tables now send all active filters (route/user/api_key), matching the trend chart
- summary tab filters the token trend by user and unions user options from both meta APIs (deduped by id)
- stabilize the filters reference so meta load no longer retriggers a second fetch on mount
This commit is contained in:
jialin
2026-06-30 17:02:17 +08:00
committed by jialin
parent a1dd1ec861
commit db17192e55
7 changed files with 105 additions and 47 deletions
@@ -3,18 +3,18 @@ import PageBox from '@/pages/_components/page-box';
import { useIntl } from '@umijs/max';
import { Table } from 'antd';
import { useEffect, useRef, useState } from 'react';
import { FilterOptionType } from '../../config/types';
import { BreakdownFilters } from '../../config/types';
import useUsersColumns from '../../hooks/use-users-columns';
import useQueryBreakdownList from '../../services/use-query-breakdown-list';
import getBreakdownRowKey from '../../utils/get-breakdown-row-key';
const Users: React.FC<{
users: FilterOptionType[];
filters: BreakdownFilters;
dateRange: { start_date: string; end_date: string };
scope: string;
pageResetKey?: number;
refreshKey?: number;
}> = ({ users, dateRange, scope, pageResetKey = 0, refreshKey = 0 }) => {
}> = ({ filters, dateRange, scope, pageResetKey = 0, refreshKey = 0 }) => {
const intl = useIntl();
const { loading, dataSource, fetchData } = useQueryBreakdownList({
@@ -71,9 +71,9 @@ const Users: React.FC<{
fetchData({
...queryParams,
group_by: ['user'],
filters: {
users
},
// Send the full filter set (route / user / api_key), not just the
// table's own dimension, so the breakdown matches the trend chart.
filters,
scope: scope,
...dateRange
});
@@ -81,12 +81,12 @@ const Users: React.FC<{
}, [
dateRange.end_date,
dateRange.start_date,
filters,
queryParams.page,
queryParams.perPage,
queryParams.sort_by,
refreshKey,
scope,
users
scope
]);
return (