iboard/scripts/refresh-news.cjs
2026-08-06 15:39:59 +08:00

13 lines
617 B
JavaScript

require('dotenv').config()
async function main() {
console.log('[News] 开始拉取...')
const t0 = Date.now()
const mod = await import('./fetchers/news.fetcher.js')
const list = await mod.fetchNewsList()
console.log('[News] 拉取 ' + list.length + ' 条, 耗时 ' + ((Date.now() - t0) / 1000).toFixed(1) + 's')
if (list.length === 0) { console.log('[News] 无数据, 跳过'); return }
const r = await mod.persistNews(list)
console.log('[News] 入库: 新增 ' + r.inserted + ' 条, 重复跳过 ' + r.skipped + ' 条')
}
main().catch((e) => { console.error('[News] 失败:', e); process.exit(1) })