Skip to content

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

chore: adjust logic for new project screen (#19449)

Kevin Grüneberg646843737503
diff --git a/apps/studio/components/interfaces/Home/ProjectUsageSection.tsx b/apps/studio/components/interfaces/Home/ProjectUsageSection.tsx
index b51d3f2e842..31604153d0b 100644
--- a/apps/studio/components/interfaces/Home/ProjectUsageSection.tsx
+++ b/apps/studio/components/interfaces/Home/ProjectUsageSection.tsx
@@ -8,19 +8,22 @@ import InformationBox from 'components/ui/InformationBox'
import { useProjectLogRequestsCountQuery } from 'data/analytics/project-log-requests-count-query'
import { useProjectLogStatsQuery } from 'data/analytics/project-log-stats-query'
import ProjectUsage from './ProjectUsage'
+import { useSelectedProject } from 'hooks'
+import dayjs from 'dayjs'
const ProjectUsageSection = observer(() => {
- const { ref: projectRef } = useParams()
+ const project = useSelectedProject()
+
const {
data: usage,
error: usageError,
isLoading,
- } = useProjectLogRequestsCountQuery({ projectRef })
+ } = useProjectLogRequestsCountQuery({ projectRef: project?.ref })
// wait for the stats to load before showing the usage section
// to eliminate multiple spinners
const { isLoading: isLogsStatsLoading } = useProjectLogStatsQuery({
- projectRef,
+ projectRef: project?.ref,
interval: 'hourly',
})
@@ -35,14 +38,17 @@ const ProjectUsageSection = observer(() => {
)
}
+ // if the project has more than 25 requests, we assume the project has usage
const hasProjectData =
- usage?.result && usage.result.length > 0 ? usage.result[0].count > 0 : false
+ usage?.result && usage.result.length > 0 ? usage.result[0].count > 25 : false
+
+ const isNewProject = dayjs(project?.inserted_at).isAfter(dayjs().subtract(2, 'day'))
return (
<>
{isLoading || isLogsStatsLoading ? (
<ProjectUsageLoadingState />
- ) : hasProjectData ? (
+ ) : hasProjectData && !isNewProject ? (
<ProjectUsage />
) : (
<NewProjectPanel />