Skip to content

Commit d586493

Browse files
db reports fix (supabase#37208)
* restore flag check * db connections charts * clean up imports * pooler label * remove max on free db connections chart
1 parent 2d0effe commit d586493

File tree

2 files changed

+11
-44
lines changed

2 files changed

+11
-44
lines changed

apps/studio/data/reports/database-charts.ts

Lines changed: 7 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { Project } from '../projects/project-detail-query'
55
import { ReportAttributes } from 'components/ui/Charts/ComposedChart.utils'
66

77
export const getReportAttributes = (org: Organization, project: Project): ReportAttributes[] => {
8-
const isFreePlan = org?.plan?.id === 'free'
98
const computeSize = project?.infra_compute_size || 'medium'
109

1110
return [
@@ -111,8 +110,9 @@ export const getReportAttributes = (org: Organization, project: Project): Report
111110
attributes: [],
112111
},
113112
{
114-
id: 'database-connections',
115-
label: 'Database connections',
113+
id: 'pooler-database-connections',
114+
label: 'Pooler to Database connections',
115+
syncId: 'database-reports',
116116
valuePrecision: 0,
117117
availableIn: ['free', 'pro'],
118118
hide: false,
@@ -126,7 +126,7 @@ export const getReportAttributes = (org: Organization, project: Project): Report
126126
{
127127
attribute: 'pg_stat_database_num_backends',
128128
provider: 'infra-monitoring',
129-
label: 'Pooler to database connections',
129+
label: 'Database connections',
130130
tooltip: 'Number of pooler connections to the database',
131131
},
132132
],
@@ -379,40 +379,11 @@ export const getReportAttributesV2: (org: Organization, project: Project) => Rep
379379
},
380380
{
381381
id: 'client-connections',
382-
label: 'Database connections',
383-
valuePrecision: 0,
384-
availableIn: ['team', 'enterprise'],
385-
hide: !isFreePlan, // [Jordi] Paid plans can see grouped client connections instead, so this chart is not needed for them. See below.
386-
showTooltip: true,
387-
showLegend: false,
388-
showMaxValue: true,
389-
hideChartType: false,
390-
showGrid: true,
391-
YAxisProps: { width: 30 },
392-
defaultChartStyle: 'line',
393-
attributes: [
394-
{
395-
attribute: 'pg_stat_database_num_backends',
396-
provider: 'infra-monitoring',
397-
label: 'Total connections',
398-
tooltip: 'Total number of client connections to the database',
399-
},
400-
{
401-
attribute: 'max_db_connections',
402-
provider: 'reference-line',
403-
label: 'Max connections',
404-
value: getConnectionLimits(computeSize).direct,
405-
tooltip: 'Max available connections for your current compute size',
406-
isMaxValue: true,
407-
},
408-
],
409-
},
410-
{
411-
id: 'client-connections',
412-
label: 'Direct Database Client Connections Grouped',
382+
label: 'Database Connections',
383+
syncId: 'database-reports',
413384
valuePrecision: 0,
414385
availableIn: ['team', 'enterprise'],
415-
hide: isFreePlan, // [Jordi] Paid plans can see grouped client connections instead, so this chart is not needed for them. See above.
386+
hide: false,
416387
showTooltip: true,
417388
showLegend: true,
418389
showMaxValue: true,
@@ -558,7 +529,6 @@ export const getReportAttributesV2: (org: Organization, project: Project) => Rep
558529
tooltip:
559530
'Disk usage by the write-ahead log. The usage depends on your WAL settings and the amount of data being written to the database',
560531
},
561-
562532
{
563533
attribute: 'pg_database_size',
564534
provider: 'infra-monitoring',

apps/studio/pages/project/[ref]/reports/database.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,11 @@ import ChartHandler from 'components/ui/Charts/ChartHandler'
2121
import Panel from 'components/ui/Panel'
2222
import { useDatabaseSelectorStateSnapshot } from 'state/database-selector'
2323
import ComposedChartHandler from 'components/ui/Charts/ComposedChartHandler'
24-
import {
25-
LogsDatePicker,
26-
DatePickerValue,
27-
} from 'components/interfaces/Settings/Logs/Logs.DatePickers'
24+
import { LogsDatePicker } from 'components/interfaces/Settings/Logs/Logs.DatePickers'
2825
import ReportStickyNav from 'components/interfaces/Reports/ReportStickyNav'
2926
import GrafanaPromoBanner from 'components/ui/GrafanaPromoBanner'
27+
import UpgradePrompt from 'components/interfaces/Settings/Logs/UpgradePrompt'
28+
import ReportChart from 'components/interfaces/Reports/ReportChart'
3029

3130
import { analyticsKeys } from 'data/analytics/keys'
3231
import { getReportAttributes, getReportAttributesV2 } from 'data/reports/database-charts'
@@ -39,11 +38,9 @@ import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'
3938
import { useReportDateRange } from 'hooks/misc/useReportDateRange'
4039
import { REPORT_DATERANGE_HELPER_LABELS } from 'components/interfaces/Reports/Reports.constants'
4140
import { formatBytes } from 'lib/helpers'
42-
import UpgradePrompt from 'components/interfaces/Settings/Logs/UpgradePrompt'
4341

4442
import type { NextPageWithLayout } from 'types'
4543
import type { MultiAttribute } from 'components/ui/Charts/ComposedChart.utils'
46-
import ReportChart from '../../../../components/interfaces/Reports/ReportChart'
4744

4845
const DatabaseReport: NextPageWithLayout = () => {
4946
return (
@@ -82,7 +79,7 @@ const DatabaseUsage = () => {
8279

8380
const isTeamsOrEnterprisePlan =
8481
!isOrgPlanLoading && (orgPlan?.id === 'team' || orgPlan?.id === 'enterprise')
85-
const showChartsV2 = false || isTeamsOrEnterprisePlan
82+
const showChartsV2 = isReportsV2 || isTeamsOrEnterprisePlan
8683

8784
const state = useDatabaseSelectorStateSnapshot()
8885
const queryClient = useQueryClient()

0 commit comments

Comments
 (0)