mirror of
https://github.com/eliasstepanik/core.git
synced 2026-01-11 23:08:27 +00:00
47 lines
830 B
TypeScript
47 lines
830 B
TypeScript
import { prisma } from "~/db.server";
|
|
|
|
export async function getIngestionLogs(
|
|
userId: string,
|
|
page: number = 1,
|
|
limit: number = 10,
|
|
) {
|
|
const user = await prisma.user.findUnique({
|
|
where: {
|
|
id: userId,
|
|
},
|
|
include: {
|
|
Workspace: true,
|
|
},
|
|
});
|
|
|
|
const skip = (page - 1) * limit;
|
|
|
|
const [ingestionLogs, total] = await Promise.all([
|
|
prisma.ingestionQueue.findMany({
|
|
where: {
|
|
workspaceId: user?.Workspace?.id,
|
|
},
|
|
skip,
|
|
take: limit,
|
|
orderBy: {
|
|
createdAt: "desc",
|
|
},
|
|
}),
|
|
prisma.ingestionQueue.count({
|
|
where: {
|
|
workspaceId: user?.Workspace?.id,
|
|
},
|
|
}),
|
|
]);
|
|
|
|
return {
|
|
ingestionLogs,
|
|
pagination: {
|
|
total,
|
|
pages: Math.ceil(total / limit),
|
|
currentPage: page,
|
|
limit,
|
|
},
|
|
};
|
|
}
|