Remove standalone podcast-checklist app; admin checklist now uses the existing checklist backend; v2.14.1
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d6d2c087b2
commit
66b7bbef52
10 files changed
+101
-683
No files matched your search
@@ -1,47 +0,0 @@
|
||||
import { randomUUID } from 'node:crypto'
|
||||
import { readFile } from 'node:fs/promises'
|
||||
import path from 'node:path'
|
||||
import { writeFile } from '../atomic-write.js'
|
||||
import { requireAdminAuth } from '../auth.js'
|
||||
import { DATA_DIR } from '../config.js'
|
||||
|
||||
const CHECKLIST_FILE = path.join(DATA_DIR, 'podcast-checklist.json')
|
||||
|
||||
export const CHECKLIST_TASK_IDS = [
|
||||
'verify_script', 'read_script', 'record', 'edit', 'mix', 'video_script', 'post_spotify',
|
||||
'update_website', 'send_email',
|
||||
]
|
||||
|
||||
const LANES = ['A', 'B']
|
||||
|
||||
function sanitizeEpisodes(raw) {
|
||||
if (!Array.isArray(raw)) return []
|
||||
return raw.slice(0, 500).filter(e => e && typeof e === 'object').map(e => ({
|
||||
id: typeof e.id === 'string' && e.id ? e.id.slice(0, 64) : randomUUID(),
|
||||
number: Number.isFinite(Number(e.number)) ? Number(e.number) : 0,
|
||||
title: typeof e.title === 'string' ? e.title.trim().slice(0, 160) : '',
|
||||
datePublished: typeof e.datePublished === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(e.datePublished) ? e.datePublished : '',
|
||||
tasks: Object.fromEntries(CHECKLIST_TASK_IDS.map(id => [id, e.tasks?.[id] === true])),
|
||||
}))
|
||||
}
|
||||
|
||||
async function load() {
|
||||
try {
|
||||
const data = JSON.parse(await readFile(CHECKLIST_FILE, 'utf8'))
|
||||
return Object.fromEntries(LANES.map(l => [l, sanitizeEpisodes(data[l])]))
|
||||
} catch {
|
||||
return { A: [], B: [] }
|
||||
}
|
||||
}
|
||||
|
||||
export function register(app) {
|
||||
app.get('/api/admin/podcast-checklist', requireAdminAuth, async (_req, res) => {
|
||||
res.json(await load())
|
||||
})
|
||||
|
||||
app.put('/api/admin/podcast-checklist', requireAdminAuth, async (req, res) => {
|
||||
const data = Object.fromEntries(LANES.map(l => [l, sanitizeEpisodes(req.body?.[l])]))
|
||||
await writeFile(CHECKLIST_FILE, JSON.stringify(data, null, 2), 'utf8')
|
||||
res.json({ ok: true })
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user