Revert "feat(request-details): implement observability settings and enhance request detail tracking"

This reverts commit cbabf5547c.
This commit is contained in:
decolua
2026-02-09 10:29:38 +07:00
parent cbabf5547c
commit 388389c972
14 changed files with 40 additions and 1647 deletions
-62
View File
@@ -1,62 +0,0 @@
import { NextResponse } from "next/server";
import { getRequestDetailsDb } from "@/lib/requestDetailsDb";
import { getProviderNodes } from "@/lib/localDb";
import { AI_PROVIDERS, getProviderByAlias } from "@/shared/constants/providers";
/**
* GET /api/usage/providers
* Returns list of unique providers from request details
*/
export async function GET() {
try {
const db = await getRequestDetailsDb();
const stmt = db.prepare(`
SELECT DISTINCT provider
FROM request_details
WHERE provider IS NOT NULL AND provider != ''
ORDER BY provider ASC
`);
const rows = stmt.all();
// Fetch all provider nodes to get names for custom providers
const providerNodes = await getProviderNodes();
const nodeMap = {};
for (const node of providerNodes) {
nodeMap[node.id] = node.name;
}
const providers = rows.map(row => {
const providerId = row.provider;
// Try to find name from various sources
let name = providerId;
// 1. Check if it's a custom provider node
if (nodeMap[providerId]) {
name = nodeMap[providerId];
}
// 2. Check predefined providers
else {
const providerConfig = getProviderByAlias(providerId) || AI_PROVIDERS[providerId];
if (providerConfig?.name) {
name = providerConfig.name;
}
}
return {
id: providerId,
name
};
});
return NextResponse.json({ providers });
} catch (error) {
console.error("[API] Failed to get providers:", error);
return NextResponse.json(
{ error: "Failed to fetch providers" },
{ status: 500 }
);
}
}
@@ -1,57 +0,0 @@
import { NextResponse } from "next/server";
import { getRequestDetails } from "@/lib/usageDb";
/**
* GET /api/usage/request-details
* Query parameters: page, pageSize (1-100), provider, model, connectionId, status, startDate, endDate
*/
export async function GET(request) {
try {
const { searchParams } = new URL(request.url);
const page = parseInt(searchParams.get("page")) || 1;
const pageSize = parseInt(searchParams.get("pageSize")) || 20;
const provider = searchParams.get("provider");
const model = searchParams.get("model");
const connectionId = searchParams.get("connectionId");
const status = searchParams.get("status");
const startDate = searchParams.get("startDate");
const endDate = searchParams.get("endDate");
if (page < 1) {
return NextResponse.json(
{ error: "Page must be >= 1" },
{ status: 400 }
);
}
if (pageSize < 1 || pageSize > 100) {
return NextResponse.json(
{ error: "PageSize must be between 1 and 100" },
{ status: 400 }
);
}
const filter = {
page,
pageSize
};
if (provider) filter.provider = provider;
if (model) filter.model = model;
if (connectionId) filter.connectionId = connectionId;
if (status) filter.status = status;
if (startDate) filter.startDate = startDate;
if (endDate) filter.endDate = endDate;
const result = await getRequestDetails(filter);
return NextResponse.json(result);
} catch (error) {
console.error("[API] Failed to get request details:", error);
return NextResponse.json(
{ error: "Failed to fetch request details" },
{ status: 500 }
);
}
}