Skip to content

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

feat: revert reports default date range

TzeYiingd4697f4c5505
diff --git a/studio/components/interfaces/Reports/Reports.constants.ts b/studio/components/interfaces/Reports/Reports.constants.ts
index fedef4cdd7e..3713345e5f5 100644
--- a/studio/components/interfaces/Reports/Reports.constants.ts
+++ b/studio/components/interfaces/Reports/Reports.constants.ts
@@ -6,25 +6,22 @@ export const LAYOUT_COLUMN_COUNT = 24
export const REPORTS_DATEPICKER_HELPERS: DatetimeHelper[] = [
{
- text: 'Last day',
+ text: 'Last 7 days',
+ calcFrom: () => dayjs().subtract(7, 'day').startOf('day').toISOString(),
calcTo: () => '',
- calcFrom: () => dayjs().subtract(1, 'day').startOf('day').toISOString(),
+ default: true,
},
{
- text: 'Last 7 days',
+ text: 'Last 14 days',
calcFrom: () => dayjs().subtract(7, 'day').startOf('day').toISOString(),
calcTo: () => '',
+ default: true,
},
{
text: 'Last 30 days',
calcFrom: () => dayjs().subtract(30, 'day').startOf('day').toISOString(),
calcTo: () => '',
},
- {
- text: 'Last 90 days',
- calcFrom: () => dayjs().subtract(90, 'day').startOf('day').toISOString(),
- calcTo: () => '',
- },
]
export const DEFAULT_QUERY_PARAMS = {
@@ -157,18 +154,18 @@ export const PRESET_CONFIG: Record<Presets, PresetConfig> = {
title: 'Auth',
queries: {
bannedUsers: {
- queryType: "db",
- sql: (_params)=> `
+ queryType: 'db',
+ sql: (_params) => `
select
count(distinct u.id) as count
from auth.users u
where u.banned_until is not null and u.banned_until > now()
limit 1
- `
- },
+ `,
+ },
unverifiedUsers: {
- queryType: "db",
- sql: (params)=> `
+ queryType: 'db',
+ sql: (params) => `
select
date_trunc('day', u.created_at) as timestamp,
count(distinct u.id) as count
@@ -176,10 +173,10 @@ from auth.users u
where u.confirmed_at is null and '${params.iso_timestamp_start}' < u.created_at
group by timestamp
order by timestamp desc
- `
- },
+ `,
+ },
signUpProviders: {
- queryType: "db",
+ queryType: 'db',
sql: (params) => `
select
sum(count(u.id)) over (order by date_trunc('day', u.created_at)) as count,
@@ -190,17 +187,17 @@ join auth.identities as i on u.id = i.user_id
where date_trunc('day', u.created_at) > '${params.iso_timestamp_start}'
group by timestamp, provider
order by timestamp desc
- `
- },
+ `,
+ },
failedMigrations: {
- queryType: "logs",
+ queryType: 'logs',
sql: `
select count(f.id)
from auth_logs
where json_value(f.event_message, "$.level") = "fatal"
and regexp_contains(f.event_message, "error executing migrations")
limit 1
-`
+`,
},
dailyActiveUsers: {
queryType: 'logs',
@@ -218,7 +215,7 @@ order by
},
cumulativeUsers: {
queryType: 'db',
- sql: params => `
+ sql: (params) => `
select
date_trunc('day', u.created_at) as timestamp,
@@ -231,7 +228,7 @@ order by timestamp desc
},
newUsers: {
queryType: 'db',
- sql: params => `
+ sql: (params) => `
select
date_trunc('day', u.created_at) as timestamp,
count(u.id) as count
diff --git a/studio/components/interfaces/Reports/Reports.utils.tsx b/studio/components/interfaces/Reports/Reports.utils.tsx
index 41e0ee4d975..f0cf2d3e2c4 100644
--- a/studio/components/interfaces/Reports/Reports.utils.tsx
+++ b/studio/components/interfaces/Reports/Reports.utils.tsx
@@ -63,11 +63,6 @@ export const usePresetReport = (hooks: PresetHookResult[]) => {
})
}
const isLoading = data.map((datum) => datum.isLoading).some((v) => v)
- const helpers = REPORTS_DATEPICKER_HELPERS.map((helper, index) => {
- if (tier?.key === 'FREE' && index === 0) return { ...helper, default: true }
- if (tier?.key === 'PRO' && index === 1) return { ...helper, default: true }
- return { ...helper, default: false }
- })
const Layout: React.FC<{ title: string }> = ({ title, children }) => (
<div className="1xl:px-28 mx-auto flex flex-col gap-4 px-5 py-6 lg:px-16 xl:px-24 2xl:px-32">
@@ -77,7 +72,7 @@ export const usePresetReport = (hooks: PresetHookResult[]) => {
onChange={handleDatepickerChange}
to={data[0]?.params?.iso_timestamp_end || ''}
from={data[0]?.params?.iso_timestamp_start || ''}
- helpers={helpers}
+ helpers={REPORTS_DATEPICKER_HELPERS}
/>
<Button
type="default"