import { prisma } from './prisma';
import { getActivePromotions } from './pricing';

// One query per page — never call this per-product, that would N+1.
export async function fetchActivePromotions() {
  const promotions = await prisma.promotion.findMany({
    include: { products: { select: { id: true } } },
  });
  return getActivePromotions(promotions);
}
