Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

chore: user v2 content count query for search (#39869)

Kevin Grüneberg312259b7043e
diff --git a/apps/studio/components/layouts/SQLEditorLayout/SQLEditorNavV2/SearchList.tsx b/apps/studio/components/layouts/SQLEditorLayout/SQLEditorNavV2/SearchList.tsx
index 1f6020cd8ef..643f1cf76a1 100644
--- a/apps/studio/components/layouts/SQLEditorLayout/SQLEditorNavV2/SearchList.tsx
+++ b/apps/studio/components/layouts/SQLEditorLayout/SQLEditorNavV2/SearchList.tsx
@@ -45,13 +45,12 @@ export const SearchList = ({ search }: SearchListProps) => {
const { data: count, isLoading: isLoadingCount } = useContentCountQuery(
{
projectRef,
- cumulative: true,
type: 'sql',
name: search,
},
{ keepPreviousData: true }
)
- const totalNumber = (count as unknown as { count: number })?.count ?? 0
+ const totalNumber = count ? count.private + count.shared : 0
const snippets = useMemo(
// [Joshen] Set folder_id to null to ensure flat list
diff --git a/apps/studio/data/content/content-count-query.ts b/apps/studio/data/content/content-count-query.ts
index d6201e01f69..513e42b54f8 100644
--- a/apps/studio/data/content/content-count-query.ts
+++ b/apps/studio/data/content/content-count-query.ts
@@ -8,11 +8,10 @@ import { contentKeys } from './keys'
type GetContentCountVariables =
operations['ContentController_getContentCountV2']['parameters']['query'] & {
projectRef?: string
- cumulative?: boolean
}
export async function getContentCount(
- { projectRef, cumulative, type, name }: GetContentCountVariables,
+ { projectRef, type, name }: GetContentCountVariables,
signal?: AbortSignal
) {
if (typeof projectRef === 'undefined') throw new Error('projectRef is required')
@@ -25,7 +24,7 @@ export async function getContentCount(
...(name && { name }),
},
},
- ...(cumulative ? {} : { headers: { Version: '2' } }),
+ headers: { Version: '2' },
signal,
})
@@ -37,15 +36,14 @@ export type ContentIdData = Awaited<ReturnType<typeof getContentCount>>
export type ContentIdError = ResponseError
export const useContentCountQuery = <TData = ContentIdData>(
- { projectRef, cumulative, type, name }: GetContentCountVariables,
+ { projectRef, type, name }: GetContentCountVariables,
{ enabled = true, ...options }: UseQueryOptions<ContentIdData, ContentIdError, TData> = {}
) =>
useQuery<ContentIdData, ContentIdError, TData>(
contentKeys.count(projectRef, type, {
- cumulative,
name,
}),
- ({ signal }) => getContentCount({ projectRef, cumulative, type, name }, signal),
+ ({ signal }) => getContentCount({ projectRef, type, name }, signal),
{
enabled: enabled && typeof projectRef !== 'undefined',
...options,
diff --git a/apps/studio/data/content/keys.ts b/apps/studio/data/content/keys.ts
index 5becc1afcbc..6c14043edb2 100644
--- a/apps/studio/data/content/keys.ts
+++ b/apps/studio/data/content/keys.ts
@@ -37,7 +37,6 @@ export const contentKeys = {
projectRef: string | undefined,
type?: string,
options?: {
- cumulative?: boolean
visibility?: string
favorite?: boolean
name?: string