MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / ModelStatsTable

Function ModelStatsTable

apps/web/src/app/admin/components/ModelStatsTable.tsx:38–566  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

36import { toast } from 'sonner';
37
38export function ModelStatsTable() {
39 const router = useRouter();
40 const searchParams = useSearchParams();
41 const [isCreateDialogOpen, setIsCreateDialogOpen] = useState(false);
42 const [editingField, setEditingField] = useState<{
43 id: string;
44 field: 'aaSlug' | 'isActive' | 'isFeatured' | 'isStealth';
45 } | null>(null);
46 const [editValue, setEditValue] = useState('');
47 const [updatingModelId, setUpdatingModelId] = useState<string | null>(null);
48
49 const currentPage = parseInt(searchParams.get('page') || '1');
50 const currentPageSize = parseInt(searchParams.get('limit') || '25');
51 const currentSearch = searchParams.get('search') || '';
52 const currentIsActive = (searchParams.get('isActive') || '') as '' | 'true' | 'false';
53
54 const { data, isLoading } = useModelStatsList({
55 page: currentPage,
56 limit: currentPageSize,
57 sortBy: 'name',
58 sortOrder: 'asc',
59 search: currentSearch,
60 isActive: currentIsActive,
61 });
62
63 const updateModel = useUpdateModel();
64 const createModel = useCreateModel();
65 const triggerStatsUpdate = useTriggerStatsUpdate();
66 const bustCache = useBustModelStatsCache();
67
68 const updateUrl = useCallback(
69 (params: Record<string, string>) => {
70 const newSearchParams = new URLSearchParams(searchParams.toString());
71 Object.entries(params).forEach(([key, value]) => {
72 if (value) {
73 newSearchParams.set(key, value);
74 } else {
75 newSearchParams.delete(key);
76 }
77 });
78 router.push(`/admin/model-stats?${newSearchParams.toString()}`);
79 },
80 [router, searchParams]
81 );
82
83 const handleSearchChange = useCallback(
84 (searchTerm: string) => {
85 updateUrl({
86 search: searchTerm,
87 page: '1',
88 limit: currentPageSize.toString(),
89 });
90 },
91 [currentPageSize, updateUrl]
92 );
93
94 const handlePageChange = useCallback(
95 (page: number) => {

Callers

nothing calls this directly

Calls 14

useModelStatsListFunction · 0.90
useUpdateModelFunction · 0.90
useCreateModelFunction · 0.90
useTriggerStatsUpdateFunction · 0.90
useBustModelStatsCacheFunction · 0.90
handleSearchChangeFunction · 0.85
saveEditFunction · 0.85
pushMethod · 0.80
formatRelativeTimeFunction · 0.70
startEditFunction · 0.70
getMethod · 0.65
toStringMethod · 0.65

Tested by

no test coverage detected