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 type = searchParams.get("type") || "all";
|
||||
|
||||
const providers = query(
|
||||
`SELECT id, name, display_name, website, status, created_at
|
||||
const [providersData, modelsData, pricingData, versionsData] = await Promise.all([
|
||||
query(
|
||||
`SELECT id, name, display_name, website, status, created_at, updated_at
|
||||
FROM ai_model_provider
|
||||
ORDER BY name`
|
||||
);
|
||||
|
||||
const models = query(
|
||||
),
|
||||
query(
|
||||
`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,
|
||||
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
|
||||
LEFT JOIN ai_model_version mv ON mv.model_id = m.id AND mv.is_default = true
|
||||
ORDER BY p.name, m.name`
|
||||
);
|
||||
|
||||
const pricing = query(
|
||||
),
|
||||
query(
|
||||
`SELECT mp.id, mp.model_version_id, mp.input_price_per_1k_tokens, mp.output_price_per_1k_tokens,
|
||||
mp.currency, mp.effective_from,
|
||||
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
|
||||
ORDER BY mp.effective_from DESC
|
||||
LIMIT 200`
|
||||
);
|
||||
|
||||
const versions = query(
|
||||
),
|
||||
query(
|
||||
`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
|
||||
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>) => ({
|
||||
id: String(r.id),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user