fix(admin): platform/ai missing await on 4 queries
This commit is contained in:
parent
e6a5828d14
commit
0a02e14bda
@ -8,13 +8,13 @@ export async function GET(req: NextRequest) {
|
|||||||
const { searchParams } = req.nextUrl;
|
const { searchParams } = req.nextUrl;
|
||||||
const type = searchParams.get("type") || "all";
|
const type = searchParams.get("type") || "all";
|
||||||
|
|
||||||
const providers = query(
|
const [providersData, modelsData, pricingData, versionsData] = await Promise.all([
|
||||||
`SELECT id, name, display_name, website, status, created_at
|
query(
|
||||||
|
`SELECT id, name, display_name, website, status, created_at, updated_at
|
||||||
FROM ai_model_provider
|
FROM ai_model_provider
|
||||||
ORDER BY name`
|
ORDER BY name`
|
||||||
);
|
),
|
||||||
|
query(
|
||||||
const models = query(
|
|
||||||
`SELECT m.id, m.name, m.modality, m.capability, m.context_length,
|
`SELECT m.id, m.name, m.modality, m.capability, m.context_length,
|
||||||
m.max_output_tokens, m.training_cutoff, m.is_open_source, m.status,
|
m.max_output_tokens, m.training_cutoff, m.is_open_source, m.status,
|
||||||
mv.model_id, mv.version,
|
mv.model_id, mv.version,
|
||||||
@ -23,9 +23,8 @@ export async function GET(req: NextRequest) {
|
|||||||
JOIN ai_model_provider p ON p.id = m.provider_id
|
JOIN ai_model_provider p ON p.id = m.provider_id
|
||||||
LEFT JOIN ai_model_version mv ON mv.model_id = m.id AND mv.is_default = true
|
LEFT JOIN ai_model_version mv ON mv.model_id = m.id AND mv.is_default = true
|
||||||
ORDER BY p.name, m.name`
|
ORDER BY p.name, m.name`
|
||||||
);
|
),
|
||||||
|
query(
|
||||||
const pricing = query(
|
|
||||||
`SELECT mp.id, mp.model_version_id, mp.input_price_per_1k_tokens, mp.output_price_per_1k_tokens,
|
`SELECT mp.id, mp.model_version_id, mp.input_price_per_1k_tokens, mp.output_price_per_1k_tokens,
|
||||||
mp.currency, mp.effective_from,
|
mp.currency, mp.effective_from,
|
||||||
m.name as model_name, mv.model_id
|
m.name as model_name, mv.model_id
|
||||||
@ -34,15 +33,13 @@ export async function GET(req: NextRequest) {
|
|||||||
JOIN ai_model m ON m.id = mv.model_id
|
JOIN ai_model m ON m.id = mv.model_id
|
||||||
ORDER BY mp.effective_from DESC
|
ORDER BY mp.effective_from DESC
|
||||||
LIMIT 200`
|
LIMIT 200`
|
||||||
);
|
),
|
||||||
|
query(
|
||||||
const versions = query(
|
|
||||||
`SELECT mv.id, mv.model_id, mv.version, mv.release_date, mv.change_log, mv.is_default, mv.status, mv.created_at
|
`SELECT mv.id, mv.model_id, mv.version, mv.release_date, mv.change_log, mv.is_default, mv.status, mv.created_at
|
||||||
FROM ai_model_version mv
|
FROM ai_model_version mv
|
||||||
ORDER BY mv.model_id, mv.version`
|
ORDER BY mv.model_id, mv.version`
|
||||||
);
|
),
|
||||||
|
]);
|
||||||
const [providersData, modelsData, pricingData, versionsData] = await Promise.all([providers, models, pricing, versions]);
|
|
||||||
|
|
||||||
const providersList = providersData.rows.map((r: Record<string, unknown>) => ({
|
const providersList = providersData.rows.map((r: Record<string, unknown>) => ({
|
||||||
id: String(r.id),
|
id: String(r.id),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user