mirror of
https://github.com/ruvnet/RuVector.git
synced 2026-05-24 22:15:18 +00:00
Major additions: - Complete Next.js studio application with 1600+ components - Docker support (Dockerfile.combined, docker-compose.yml) - GCP deployment documentation and benchmarks - SQL benchmark scripts for performance testing - Sentry integration for monitoring - Comprehensive test suite and mocks Studio features: - Dashboard and admin interfaces - Data visualization components - Authentication and user management - API integration with RuVector backend - Static data and public assets 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
57 lines
1.8 KiB
TypeScript
57 lines
1.8 KiB
TypeScript
import { useQuery } from '@tanstack/react-query'
|
|
|
|
import type { components } from 'data/api'
|
|
import { get, handleError } from 'data/fetchers'
|
|
import { IS_PLATFORM } from 'lib/constants'
|
|
import type { ResponseError, UseCustomQueryOptions } from 'types'
|
|
import { usageKeys } from './keys'
|
|
|
|
export type OrgUsageVariables = {
|
|
orgSlug?: string
|
|
projectRef?: string | null
|
|
start?: Date
|
|
end?: Date
|
|
}
|
|
|
|
export type OrgUsageResponse = components['schemas']['OrgUsageResponse']
|
|
export type OrgMetricsUsage = components['schemas']['OrgUsageResponse']['usages'][0]
|
|
|
|
export async function getOrgUsage(
|
|
{ orgSlug, projectRef, start, end }: OrgUsageVariables,
|
|
signal?: AbortSignal
|
|
): Promise<OrgUsageResponse> {
|
|
if (!orgSlug) throw new Error('orgSlug is required')
|
|
const { data, error } = await get(`/platform/organizations/{slug}/usage`, {
|
|
params: {
|
|
path: { slug: orgSlug },
|
|
query: {
|
|
project_ref: projectRef ?? undefined,
|
|
start: start?.toISOString(),
|
|
end: end?.toISOString(),
|
|
},
|
|
},
|
|
signal,
|
|
})
|
|
if (error) handleError(error)
|
|
return data
|
|
}
|
|
|
|
export type OrgUsageData = Awaited<ReturnType<typeof getOrgUsage>>
|
|
export type OrgUsageError = ResponseError
|
|
|
|
export const useOrgUsageQuery = <TData = OrgUsageData>(
|
|
{ orgSlug, projectRef, start, end }: OrgUsageVariables,
|
|
{ enabled = true, ...options }: UseCustomQueryOptions<OrgUsageData, OrgUsageError, TData> = {}
|
|
) =>
|
|
useQuery<OrgUsageData, OrgUsageError, TData>({
|
|
queryKey: usageKeys.orgUsage(
|
|
orgSlug,
|
|
projectRef ?? undefined,
|
|
start?.toISOString(),
|
|
end?.toISOString()
|
|
),
|
|
queryFn: ({ signal }) => getOrgUsage({ orgSlug, projectRef, start, end }, signal),
|
|
enabled: enabled && IS_PLATFORM && typeof orgSlug !== 'undefined',
|
|
staleTime: 1000 * 60 * 60,
|
|
...options,
|
|
})
|