Files
supabase/apps/studio/data/reports/database-report-query.ts
Jordi Enric 15fcb7dc49 fix(studio): refresh observability charts for the selected range FE-5122 (#53931)
## Problem

A custom date range in a Storage report URL could show one window in the
header and another in the charts. Refresh also left Database Size and
several Auth charts showing cached results.

## Fix

Use the selected window for all Storage report requests, run the
Database Size query on refresh, and refresh Auth Usage, Errors and
Latency alongside the shared API charts.

## How to test

- Open Storage with a custom start and end time in the URL. Inspect the
chart requests on load and after Refresh. Both sets should use those
exact timestamps.
- Refresh the Database report and check that the large objects query
runs again.
- Open Auth with a fixed range and press Shift+R. The Usage, Errors,
Latency and API charts should request fresh data for the same range.

Fixes [FE-5122](https://linear.app/supabase/issue/FE-5122).
2026-11-24 15:31:11 +01:00

34 lines
961 B
TypeScript

import { useParams } from 'common'
import { PRESET_CONFIG } from '@/components/interfaces/Reports/Reports.constants'
import { queriesFactory } from '@/components/interfaces/Reports/Reports.utils'
import { DbQueryHook } from '@/hooks/analytics/useDbQuery'
export const useDatabaseReport = () => {
const { ref: projectRef } = useParams()
const queryHooks = queriesFactory<keyof typeof PRESET_CONFIG.database.queries>(
PRESET_CONFIG.database.queries,
projectRef ?? 'default'
)
const largeObjects = queryHooks.largeObjects() as DbQueryHook
const activeHooks = [largeObjects]
const isPending = activeHooks.some((hook) => hook.isLoading)
return {
data: {
largeObjects: largeObjects.data,
},
errors: {
largeObjects: largeObjects.error,
},
params: {
largeObjects: largeObjects.params,
},
largeObjectsSql: largeObjects.resolvedSql,
isPending,
refresh: () => largeObjects.runQuery(),
}
}