MCPcopy Create free account
hub / github.com/Tron521/codex-console-temp / loadTodayStats

Function loadTodayStats

static/js/app.js:2067–2089  ·  view source on GitHub ↗
(silent = true)

Source from the content-addressed store, hash-verified

2065}
2066
2067async function loadTodayStats(silent = true) {
2068 try {
2069 const data = await api.get('/registration/stats');
2070 const todayByStatus = data?.today_by_status || {};
2071 const hasTodaySuccess = data?.today_success != null || todayByStatus.completed != null;
2072 const hasTodayFailed = data?.today_failed != null || todayByStatus.failed != null;
2073 const success = Number(data?.today_success ?? todayByStatus.completed ?? 0);
2074 const failed = Number(data?.today_failed ?? todayByStatus.failed ?? 0);
2075 const fallbackTotal = Number(data?.today_total ?? data?.today_count ?? 0);
2076 const total = hasTodaySuccess || hasTodayFailed ? (success + failed) : fallbackTotal;
2077 const safeTotal = Number.isFinite(total) ? total : 0;
2078 const computedRate = safeTotal > 0 ? (success / safeTotal) * 100 : 0;
2079 const rate = hasTodaySuccess || hasTodayFailed
2080 ? computedRate
2081 : Number(data?.today_success_rate ?? computedRate);
2082 renderTodayStats(safeTotal, success, failed, Number.isFinite(rate) ? rate : 0);
2083 } catch (error) {
2084 console.error('加载今日统计失败:', error);
2085 if (!silent) {
2086 toast.error('加载今日统计失败');
2087 }
2088 }
2089}
2090
2091function updateTodayStatsResetText() {
2092 if (!elements.todayStatsReset) return;

Callers 2

app.jsFile · 0.85
startTodayStatsPollingFunction · 0.85

Calls 3

renderTodayStatsFunction · 0.85
errorMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected