core/apps/webapp/app/routes/api.v1.ingestion-queue.status.tsx
Harshith Mullapudi ef320394d5 1. Feat: added ingestion floating status
2. OAuth for mcp
2025-07-15 22:02:41 +05:30

41 lines
944 B
TypeScript

import { type LoaderFunctionArgs, json } from "@remix-run/node";
import { prisma } from "~/db.server";
import { requireUserId } from "~/services/session.server";
export async function loader({ request }: LoaderFunctionArgs) {
const userId = await requireUserId(request);
const user = await prisma.user.findUnique({
where: { id: userId },
include: { Workspace: true },
});
if (!user?.Workspace) {
throw new Response("Workspace not found", { status: 404 });
}
const activeIngestionQueue = await prisma.ingestionQueue.findMany({
where: {
workspaceId: user.Workspace.id,
status: {
in: ["PENDING", "PROCESSING"],
},
},
select: {
id: true,
status: true,
createdAt: true,
error: true,
data: true,
},
orderBy: {
createdAt: "desc",
},
});
return json({
queue: activeIngestionQueue,
count: activeIngestionQueue.length,
});
}