25 lines
492 B
TypeScript
25 lines
492 B
TypeScript
"use server";
|
|
|
|
import { prisma } from "@/lib/prisma";
|
|
|
|
export type GalleryVariantStats = {
|
|
total: number;
|
|
withGallery: number;
|
|
missing: number;
|
|
};
|
|
|
|
export async function getGalleryVariantStats(): Promise<GalleryVariantStats> {
|
|
const [total, withGallery] = await Promise.all([
|
|
prisma.artwork.count(),
|
|
prisma.artwork.count({
|
|
where: { variants: { some: { type: "gallery" } } },
|
|
}),
|
|
]);
|
|
|
|
return {
|
|
total,
|
|
withGallery,
|
|
missing: total - withGallery,
|
|
};
|
|
}
|