Files
ObsidianHome/小鱼/.cdp/thresholds.mjs
T
2026-11-05 15:16:24 +08:00

18 lines
893 B
JavaScript

import fs from 'node:fs';
const J = JSON.parse(fs.readFileSync('.cdp/out/items-7d-30d.json', 'utf8'));
const N = s => Number(s) || 0;
const L = [];
for (const dt of ['recent7d', 'recent30d']) {
const it = J.data[dt].items;
L.push('=== ' + dt + ' 零成交 · 不同曝光阈值 ===');
for (const th of [300, 400, 500, 1000]) {
const g = it.filter(x => N(x.pv) >= th && N(x.ord) === 0);
L.push(` 曝光>=${th}: ${g.length} 个,吃掉曝光 ${g.reduce((a, b) => a + N(b.pv), 0)}`);
}
const g400 = it.filter(x => N(x.pv) >= 400 && N(x.ord) === 0).sort((a, b) => N(b.pv) - N(a.pv));
L.push(' 曝光>=400 明细(前 12):');
g400.slice(0, 12).forEach(x => L.push(` ${x.id} 曝光${x.pv} 浏览人${x.ipvUv} 询单${x.chat} ¥${x.price} ${x.c4} | ${String(x.name).slice(0, 30)}`));
L.push('');
}
fs.writeFileSync('.cdp/out/thresholds.txt', L.join('\n'), 'utf8');