Files
EpicNext-Cms/src/lib/services/watch.ts
T
openhands df38dccbf1
Local Build and Deploy / deploy (push) Failing after 46s
style: format code biome
2026-07-13 21:57:41 +02:00

24 lines
702 B
TypeScript

import { unstable_cache } from "next/cache";
import { prisma } from "@/lib/prisma";
/**
* Returns the set of user IDs that the given staff member has marked as
* "watch". Cached 60s + tag-invalidated by toggleUserWatch.
*/
export async function getWatchedUserIds(staffId: number): Promise<Set<number>> {
const ids = await getCachedWatchedIds(staffId);
return new Set(ids);
}
const getCachedWatchedIds = unstable_cache(
async (staffId: number): Promise<number[]> => {
const rows = await prisma.userWatch.findMany({
where: { staffId },
select: { targetUserId: true },
});
return rows.map((r) => r.targetUserId);
},
["user-watch-list"],
{ revalidate: 60, tags: ["user-watch"] },
);