From 4ae60aabdae3b9aca8dbf51efa63a4b3549944da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daphn=C3=A9=20Popin?= Date: Mon, 13 Jan 2025 12:12:41 +0100 Subject: [PATCH] Update usage query to filter out private assistants and only count them --- .../components/spaces/SpaceResourcesList.tsx | 3 +- front/components/spaces/UsedByButton.tsx | 17 +- front/lib/api/agent_data_sources.ts | 250 +++++++++++++++--- types/src/front/data_source.ts | 5 +- 4 files changed, 232 insertions(+), 43 deletions(-) diff --git a/front/components/spaces/SpaceResourcesList.tsx b/front/components/spaces/SpaceResourcesList.tsx index a1bf0710abdde..a37edd5ef759c 100644 --- a/front/components/spaces/SpaceResourcesList.tsx +++ b/front/components/spaces/SpaceResourcesList.tsx @@ -131,7 +131,8 @@ const getTableColumns = ({ const usedByColumn = { header: "Used by", - accessorFn: (row: RowData) => row.dataSourceView.usage?.count ?? 0, + accessorFn: (row: RowData) => + row.dataSourceView.usage?.totalAgentCount ?? 0, id: "usedBy", meta: { width: "6rem", diff --git a/front/components/spaces/UsedByButton.tsx b/front/components/spaces/UsedByButton.tsx index 826d34be0f027..23654cb0ee403 100644 --- a/front/components/spaces/UsedByButton.tsx +++ b/front/components/spaces/UsedByButton.tsx @@ -8,6 +8,7 @@ import { ScrollArea, } from "@dust-tt/sparkle"; import type { DataSourceWithAgentsUsageType } from "@dust-tt/types"; +import { pluralize } from "@dust-tt/types"; export const UsedByButton = ({ usage, @@ -16,13 +17,13 @@ export const UsedByButton = ({ usage: DataSourceWithAgentsUsageType; onItemClick: (assistantSid: string) => void; }) => { - return usage.count === 0 ? ( + return usage.totalAgentCount === 0 ? (