chore(repo): initialize planarchy workspace
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import type { PrismaClient } from "@planarchy/db";
|
||||
|
||||
export interface GetDashboardTopValueResourcesInput {
|
||||
limit: number;
|
||||
userRole: string;
|
||||
}
|
||||
|
||||
export async function getDashboardTopValueResources(
|
||||
db: PrismaClient,
|
||||
input: GetDashboardTopValueResourcesInput,
|
||||
) {
|
||||
const settings = await db.systemSettings.findUnique({
|
||||
where: { id: "singleton" },
|
||||
});
|
||||
|
||||
const visibleRoles =
|
||||
(settings?.scoreVisibleRoles as unknown as string[]) ?? ["ADMIN", "MANAGER"];
|
||||
|
||||
if (!visibleRoles.includes(input.userRole)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return db.resource.findMany({
|
||||
where: { isActive: true, valueScore: { not: null } },
|
||||
select: {
|
||||
id: true,
|
||||
eid: true,
|
||||
displayName: true,
|
||||
chapter: true,
|
||||
valueScore: true,
|
||||
lcrCents: true,
|
||||
},
|
||||
orderBy: { valueScore: "desc" },
|
||||
take: input.limit,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user