migrate organizations from clerk to in-house

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-06-16 19:32:53 +02:00
parent 84ac68fe63
commit c7dbc2f7c4
27 changed files with 523 additions and 294 deletions

View File

@@ -58,15 +58,34 @@ export async function getCurrentProjects(organizationSlug: string) {
return [];
}
return db.project.findMany({
where: {
organizationSlug,
},
include: {
access: true,
},
orderBy: {
eventsCount: 'desc',
},
});
const [projects, members, access] = await Promise.all([
db.project.findMany({
where: {
organizationSlug,
},
}),
db.member.findMany({
where: {
userId: session.userId,
organizationId: organizationSlug,
},
}),
db.projectAccess.findMany({
where: {
userId: session.userId,
},
}),
]);
if (members.length === 0) {
return [];
}
if (access.length > 0) {
return projects.filter((project) =>
access.some((a) => a.projectId === project.id)
);
}
return projects;
}