core/apps/webapp/app/routes/api.v1.clusters.drift.tsx
Harshith Mullapudi 4882f227d2
Feat: clusters (#37)
* Feat: clustering fact statements

* Feat: cluster drift

* Feat: add recall count and model to search

* Feat: Github integration

* Fix: clustering UI

* Improve graph

* Bump: new version

---------

Co-authored-by: Manoj K <saimanoj58@gmail.com>
2025-08-05 15:31:15 +05:30

29 lines
824 B
TypeScript

import { json, type LoaderFunctionArgs } from "@remix-run/node";
import { ClusteringService } from "~/services/clustering.server";
import { logger } from "~/services/logger.service";
import { requireUser } from "~/services/session.server";
const clusteringService = new ClusteringService();
export async function loader({ request }: LoaderFunctionArgs) {
try {
const user = await requireUser(request);
const driftMetrics = await clusteringService.detectClusterDrift(user.id);
return json({
success: true,
data: driftMetrics
});
} catch (error) {
logger.error("Error checking cluster drift:", { error });
return json(
{
success: false,
error: error instanceof Error ? error.message : "Unknown error"
},
{ status: 500 }
);
}
}