R33: 工作台热点数据页更新按钮(纯图标+30min冷却防重+整页重建+CDP冒烟全绿)
This commit is contained in:
1 parent
9445b76485
commit
fa55d3eecb
6 files changed
+243
-4
No files matched your search
@@ -409,6 +409,32 @@ function rankingMeta(board = 'week') {
|
||||
return { dates, categories: collectCategories(board, files) };
|
||||
}
|
||||
|
||||
// 榜单数据新鲜度(更新防重依据,09-03 新增):递归扫描 RANKING_DIR(三榜子目录 + 根目录旧平铺)全部 .json,
|
||||
// 返回最新落盘文件的 mtime(=最近一次成功抓取完成时刻,任务落盘即刷新)
|
||||
function rankingFreshness() {
|
||||
const out = { exists: fs.existsSync(RANKING_DIR), latestMtime: 0, latestFile: '', latestDate: '', files: 0 };
|
||||
if (!out.exists) return out;
|
||||
const walk = (dir) => {
|
||||
let entries = [];
|
||||
try { entries = fs.readdirSync(dir, { withFileTypes: true }); } catch (e) { return; }
|
||||
for (const en of entries) {
|
||||
const full = path.join(dir, en.name);
|
||||
if (en.isDirectory()) walk(full);
|
||||
else if (/\.json$/i.test(en.name)) {
|
||||
out.files++;
|
||||
try {
|
||||
const st = fs.statSync(full);
|
||||
if (st.mtimeMs > out.latestMtime) { out.latestMtime = st.mtimeMs; out.latestFile = full; }
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
};
|
||||
walk(RANKING_DIR);
|
||||
const m = String(out.latestFile).match(/(\d{4}-\d{2}-\d{2})\.json$/);
|
||||
if (m) out.latestDate = m[1];
|
||||
return out;
|
||||
}
|
||||
|
||||
function parseNum(v) {
|
||||
const s = String(v ?? '');
|
||||
const m = s.match(/^([\d.]+)\s*(w|万)?$/i);
|
||||
@@ -541,6 +567,6 @@ function getRewriteStats(account = '') {
|
||||
module.exports = {
|
||||
dbAvailable, setFavorite, batchDelete, listTracks, listAccounts, listAccountVideos, getPersona, getAccountAnalysis,
|
||||
listVideos, getVideoDetail, getVideoScript, listRewrites, listStoryboards, listRecentScripts,
|
||||
getReviewDetail, getReviewFull, getStats, rankingMeta, getRanking, DSH_DB, RANKING_DIR,
|
||||
getReviewDetail, getReviewFull, getStats, rankingMeta, getRanking, rankingFreshness, DSH_DB, RANKING_DIR,
|
||||
listCustomScripts, getCustomScript, saveScript, getRewriteStats,
|
||||
};
|
||||
Reference in new issue
Block a user