feat: autogen service — content_queue, autogen_settings, TOPIC_BANK, cron API

This commit is contained in:
Alexey Pavlov
2026-05-31 14:48:38 +03:00
parent e5e7e9ef98
commit 3372574b32
4 changed files with 255 additions and 3 deletions
+4 -3
View File
@@ -70,7 +70,7 @@ async function getAllTags() {
* Генерирует и сохраняет статью.
* @param {object} opts - { topic, keywords, tags, autoPublish }
*/
async function generateAndSaveArticle({ topic, keywords = [], tags = [], autoPublish = true }) {
async function generateAndSaveArticle({ topic, keywords = [], tags = [], autoPublish = true, category = 'ai-tools' }) {
// job
const { rows: jobRows } = await query(
`INSERT INTO generation_jobs (type, topic, status) VALUES ('article',$1,'processing') RETURNING id`,
@@ -116,11 +116,12 @@ async function generateAndSaveArticle({ topic, keywords = [], tags = [], autoPub
const readingTime = estimateReadingTime(content);
const { rows: artRows } = await query(
`INSERT INTO articles (slug, title, excerpt, content, tags, reading_time, status, job_id, seo_title, seo_descr)
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10) RETURNING *`,
`INSERT INTO articles (slug, title, excerpt, content, tags, category, reading_time, status, job_id, seo_title, seo_descr)
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11) RETURNING *`,
[
slug, title, excerpt, content,
JSON.stringify(tags),
category,
readingTime,
autoPublish ? 'published' : 'draft',
jobId,