feat: expose optimizer workflow api
This commit is contained in:
@@ -245,6 +245,36 @@ export function getArticleJob(dbPath: string | undefined, id: string) {
|
||||
});
|
||||
}
|
||||
|
||||
export function updateArticleJob(
|
||||
dbPath: string | undefined,
|
||||
id: string,
|
||||
changes: Partial<Pick<ArticleJob, "brand_template_id" | "status" | "export_paths">>,
|
||||
) {
|
||||
return withDb(dbPath, (db) => {
|
||||
const existing = getArticleJob(dbPath, id);
|
||||
if (!existing) return null;
|
||||
const updated = {
|
||||
brand_template_id: changes.brand_template_id ?? existing.brand_template_id,
|
||||
status: changes.status ?? existing.status,
|
||||
export_paths: changes.export_paths ?? existing.export_paths,
|
||||
updated_at: nowIso(),
|
||||
};
|
||||
db.prepare(
|
||||
`update article_jobs set
|
||||
brand_template_id = @brand_template_id,
|
||||
status = @status,
|
||||
export_paths = @export_paths,
|
||||
updated_at = @updated_at
|
||||
where id = @id`,
|
||||
).run({
|
||||
id,
|
||||
...updated,
|
||||
export_paths: serialize(updated.export_paths),
|
||||
});
|
||||
return getArticleJob(dbPath, id);
|
||||
});
|
||||
}
|
||||
|
||||
export function saveFactCard(
|
||||
dbPath: string | undefined,
|
||||
jobId: string,
|
||||
|
||||
Reference in New Issue
Block a user