import db from '@admin/db' import { webhookDeliveries } from '@admin/db/schema' import { count } from 'drizzle-orm' import { cacheLife } from 'next/cache' export async function countWebhookDeliveries(): Promise { 'use cache' // Not `seconds`: its one-minute expiry is a dynamic hole that Next keeps // out of the prerendered shell, and the page awaits this count outside // Suspense. The count only ever flips from zero once. cacheLife('minutes') const [row] = await db.select({ count: count() }).from(webhookDeliveries) return Number(row?.count ?? 0) }