src/utils/blog-shares.tsimport 'server-only'import { prisma } from '@/utils/prisma'import { kv, shareCountKey } from '@/utils/kv'const TTL_SECONDS = 60 * 60 * 24 // 24hexport async function invalidateShare(id: number): Promise<void> {await kv.del(shareCountKey(id))}async function readShareCountsFromDb(ids: number[]): Promise<Record<number, number>> {if (ids.length === 0) return {}const intentRows = await prisma.blogShareIntent.groupBy({by: ['post_id'],where: { post_id: { in: ids } },_sum: { count: true },})const totals: Record<number, number> = {}
Showing the first 20 lines.
Get full code