feat: export optimized article files

This commit is contained in:
Codex
2026-06-21 23:42:37 +08:00
parent 67f19f8550
commit 68310f6e00
3 changed files with 191 additions and 0 deletions
@@ -7,6 +7,7 @@ import {
saveQaReport,
updateArticleJob,
} from "../../../../../lib/db/repositories";
import { writeJobExports } from "../../../../../lib/workflow/exporter";
import { runOptimizationWorkflow } from "../../../../../lib/workflow/orchestrator";
interface RouteContext {
@@ -45,13 +46,23 @@ export async function POST(_request: Request, context: RouteContext) {
optimizedArticle.revision ?? 1,
result.qaReport,
);
const exportPaths =
qaReport.overall_status === "fail"
? {}
: await writeJobExports({
jobId,
article: optimizedArticle,
qaReport,
});
updateArticleJob(undefined, jobId, {
status: qaReport.overall_status === "fail" ? "qa_failed" : "optimized",
export_paths: exportPaths,
});
return NextResponse.json({
optimizedArticle,
qaReport,
exportPaths,
rewriteRounds: result.rewrite_rounds,
stoppedAfterMaxRewrites: result.stopped_after_max_rewrites,
});