Fixes for build ready

This commit is contained in:
2025-12-28 00:36:49 +01:00
parent d366dd4e18
commit e2fd4df221
5 changed files with 27 additions and 20 deletions

View File

@ -2,16 +2,21 @@
import { prisma } from "@/lib/prisma";
export async function isDescendant(tagId: string, possibleAncestorId: string) {
export async function isDescendant(tagId: string, possibleAncestorId: string): Promise<boolean> {
// Walk upwards from possibleAncestorId; if we hit tagId, it's a cycle.
let current: string | null = possibleAncestorId;
while (current) {
if (current === tagId) return true;
const t = await prisma.artTag.findUnique({
where: { id: current },
select: { parentId: true },
});
const t: { parentId: string | null } | null =
await prisma.artTag.findUnique({
where: { id: current },
select: { parentId: true },
});
current = t?.parentId ?? null;
}
return false;
}