diff --git a/web/src/api/buster_rest/metrics/interfaces.ts b/web/src/api/buster_rest/metrics/interfaces.ts index bd055e58c..9ca04fa7b 100644 --- a/web/src/api/buster_rest/metrics/interfaces.ts +++ b/web/src/api/buster_rest/metrics/interfaces.ts @@ -12,8 +12,6 @@ export interface ListMetricsParams { page_token: number; /** The number of items to return per page */ page_size: number; - /** Flag to enable admin view with additional permissions and data */ - admin_view?: boolean; /** Filtering options for metrics based on verification status */ status?: VerificationStatus[] | null; } diff --git a/web/src/api/buster_rest/metrics/queryRequests.ts b/web/src/api/buster_rest/metrics/queryRequests.ts index 7b2ba1b85..e033c8e5d 100644 --- a/web/src/api/buster_rest/metrics/queryRequests.ts +++ b/web/src/api/buster_rest/metrics/queryRequests.ts @@ -13,6 +13,7 @@ import { import type { GetMetricParams, ListMetricsParams } from './interfaces'; import { upgradeMetricToIMetric } from '@/lib/chat'; import { queryKeys } from '@/api/query_keys'; +import { useMemo } from 'react'; export const useGetMetric = (params: GetMetricParams) => { const queryFn = useMemoizedFn(async () => { @@ -40,13 +41,18 @@ export const prefetchGetMetric = async (params: GetMetricParams, queryClientProp return queryClient; }; -export const useGetMetricsList = (params: ListMetricsParams) => { +export const useGetMetricsList = (params: Omit) => { + const compiledParams: ListMetricsParams = useMemo( + () => ({ ...params, page_token: 0, page_size: 3000 }), + [params] + ); + const queryFn = useMemoizedFn(() => { - return listMetrics(params); + return listMetrics(compiledParams); }); const res = useQuery({ - ...queryKeys.metricsGetList(params), + ...queryKeys.metricsGetList(compiledParams), queryFn }); diff --git a/web/src/app/app/(primary_layout)/logs/page.tsx b/web/src/app/app/(primary_layout)/logs/page.tsx index 679154103..2de78974d 100644 --- a/web/src/app/app/(primary_layout)/logs/page.tsx +++ b/web/src/app/app/(primary_layout)/logs/page.tsx @@ -1,6 +1,5 @@ -import { MetricListContainer } from '@/controllers/MetricListContainer'; import React from 'react'; export default function LogsPage() { - return ; + return
THIS SHOULD BE CHATS
; } diff --git a/web/src/app/app/(primary_layout)/metrics/page.tsx b/web/src/app/app/(primary_layout)/metrics/page.tsx index 791ce7fb6..806ab0032 100644 --- a/web/src/app/app/(primary_layout)/metrics/page.tsx +++ b/web/src/app/app/(primary_layout)/metrics/page.tsx @@ -1,5 +1,5 @@ import { MetricListContainer } from '@/controllers/MetricListContainer'; export default function MetricsPage() { - return ; + return ; } diff --git a/web/src/context/Metrics/BusterMetricsListProvider/index.ts b/web/src/context/Metrics/BusterMetricsListProvider/index.ts deleted file mode 100644 index 2740a7f46..000000000 --- a/web/src/context/Metrics/BusterMetricsListProvider/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './useBusterMetricListByFilter'; diff --git a/web/src/context/Metrics/BusterMetricsListProvider/useBusterMetricListByFilter.tsx b/web/src/context/Metrics/BusterMetricsListProvider/useBusterMetricListByFilter.tsx deleted file mode 100644 index 027490297..000000000 --- a/web/src/context/Metrics/BusterMetricsListProvider/useBusterMetricListByFilter.tsx +++ /dev/null @@ -1,28 +0,0 @@ -'use client'; - -import React, { useMemo } from 'react'; -import { VerificationStatus } from '@/api/asset_interfaces/share'; -import { type ListMetricsParams, useGetMetricsList } from '@/api/buster_rest/metrics'; - -export const useBusterMetricListByFilter = (params: { - filters: VerificationStatus[]; - admin_view: boolean; -}) => { - const metricListFilters: ListMetricsParams = useMemo( - () => ({ - filters: params.filters, - admin_view: params.admin_view, - page_token: 0, - page_size: 3000 - }), - [params.filters.join(','), params.admin_view] - ); - - const { data: metricList, isFetching, isFetched } = useGetMetricsList(metricListFilters); - - return { - metricList, - isFetching, - isFetched - }; -}; diff --git a/web/src/context/Metrics/index.ts b/web/src/context/Metrics/index.ts index b8f731e95..61a3a53c1 100644 --- a/web/src/context/Metrics/index.ts +++ b/web/src/context/Metrics/index.ts @@ -1,3 +1,2 @@ -export * from './BusterMetricsListProvider'; export * from './BusterMetricsIndividualProvider'; export * from './BusterMetricProvider'; diff --git a/web/src/controllers/MetricListContainer/MetricItemsContainer.tsx b/web/src/controllers/MetricListContainer/MetricItemsContainer.tsx index ca0948ae7..dc77ceb68 100644 --- a/web/src/controllers/MetricListContainer/MetricItemsContainer.tsx +++ b/web/src/controllers/MetricListContainer/MetricItemsContainer.tsx @@ -18,9 +18,8 @@ import { useCreateListByDate } from '@/components/ui/list/useCreateListByDate'; export const MetricItemsContainer: React.FC<{ metrics: BusterMetricListItem[]; className?: string; - type: 'logs' | 'metrics'; loading: boolean; -}> = ({ type, metrics = [], className = '', loading }) => { +}> = React.memo(({ metrics = [], className = '', loading }) => { const [selectedRowKeys, setSelectedRowKeys] = useState([]); const renderedDates = useRef>({}); const renderedOwners = useRef>({}); @@ -118,7 +117,7 @@ export const MetricItemsContainer: React.FC<{ columns={columns} onSelectChange={onSelectChange} selectedRowKeys={selectedRowKeys} - emptyState={} + emptyState={} /> ); -}; - +}); +MetricItemsContainer.displayName = 'MetricItemsContainer'; const EmptyState: React.FC<{ loading: boolean; - type: 'logs' | 'metrics'; -}> = React.memo(({ loading, type }) => { +}> = React.memo(({ loading }) => { if (loading) { return <>; } - if (type === 'logs') { - return ( - - ); - } - return ( = ({ type }) => { +export const MetricListContainer: React.FC<{}> = ({}) => { const [filters, setFilters] = useState([]); - const adminView = type === 'logs'; - const { metricList, isFetched } = useBusterMetricListByFilter({ - filters, - admin_view: adminView - }); - - const onSetFilters = useMemoizedFn((newFilters: VerificationStatus[]) => { - setFilters(newFilters); - }); - - useMount(async () => { - onSetFilters([]); - }); + const { data: metricList, isFetching, isFetched } = useGetMetricsList({ status: filters }); return ( - }> + }> void; -}> = ({ type, filters, onSetFilters }) => { - const title = type === 'logs' ? 'Logs' : 'Metrics'; +}> = React.memo(({ filters, onSetFilters }) => { const showFilters: boolean = true; return (
- {title} - {showFilters && ( - - )} + {'Metrics'} + {showFilters && }
); -}; +}); +MetricListHeader.displayName = 'MetricListHeader'; const options: SegmentedItem[] = [ { @@ -43,10 +40,9 @@ const options: SegmentedItem[] = [ ]; const MetricsFilters: React.FC<{ - type: 'logs' | 'metrics'; filters: VerificationStatus[]; onSetFilters: (filters: VerificationStatus[]) => void; -}> = React.memo(({ type, filters, onSetFilters }) => { +}> = React.memo(({ filters, onSetFilters }) => { const selectedOption: SegmentedItem | undefined = useMemo(() => { return ( options.find((option) => {