新增优化案例API
This commit is contained in:
@@ -22,12 +22,22 @@ export async function POST(request: Request, context: RouteContext) {
|
||||
return NextResponse.json({ error: "Publication not found" }, { status: 404 });
|
||||
}
|
||||
|
||||
const scoringRun = await repository.getLatestScoringRun(
|
||||
publication.job_id,
|
||||
publication.revision,
|
||||
);
|
||||
const qaReport = await repository.getLatestQaReport(publication.job_id);
|
||||
if (!scoringRun || !qaReport) {
|
||||
const scoringRun = publication.result_version_id
|
||||
? await repository.getLatestScoringRunForResultVersion(
|
||||
publication.result_version_id,
|
||||
)
|
||||
: publication.job_id && publication.revision
|
||||
? await repository.getLatestScoringRun(
|
||||
publication.job_id,
|
||||
publication.revision,
|
||||
)
|
||||
: null;
|
||||
const qaReport = publication.job_id
|
||||
? await repository.getLatestQaReport(publication.job_id)
|
||||
: null;
|
||||
const manualInput = await request.json();
|
||||
|
||||
if (!publication.result_version_id && (!scoringRun || !qaReport)) {
|
||||
return NextResponse.json(
|
||||
{ error: "Score the optimized revision before recording performance" },
|
||||
{ status: 409 },
|
||||
@@ -40,9 +50,15 @@ export async function POST(request: Request, context: RouteContext) {
|
||||
await adapter.fetch({
|
||||
publication,
|
||||
window_label: "manual",
|
||||
manualInput: await request.json(),
|
||||
manualInput,
|
||||
}),
|
||||
);
|
||||
if (!scoringRun || !qaReport) {
|
||||
return NextResponse.json(
|
||||
{ snapshot, calibrationEvent: null },
|
||||
{ status: 201 },
|
||||
);
|
||||
}
|
||||
const calibrationEvent = await repository.saveCalibrationEvent(
|
||||
createCalibrationEvent({ scoringRun, qaReport, snapshot }),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user