MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / refreshReports

Function refreshReports

deployments/desktop/static/reports.js:337–360  ·  view source on GitHub ↗
(options = {})

Source from the content-addressed store, hash-verified

335 }
336
337 async function refreshReports(options = {}) {
338 ensureReportsDom();
339 const userId = activeUser();
340 if (!userId) return;
341 const scopedUser = byId("reportsCurrentOnly").checked ? userId : "";
342 const q = byId("reportQuery").value.trim();
343 const days = Number(byId("reportDays").value || 30);
344 const exactDate = byId("reportDate").value || "";
345 const data = await api(`/api/reports?user_id=${encodeURIComponent(scopedUser)}&q=${encodeURIComponent(q)}&days=${encodeURIComponent(days)}&date=${encodeURIComponent(exactDate)}&limit=${REPORT_LIST_LIMIT}`);
346 uiState.reports = data.reports || [];
347 const sourceDirs = data.source_dirs || [];
348 const filters = [];
349 if (exactDate) filters.push(`date=${exactDate}`);
350 if (scopedUser) filters.push(`user=${scopedUser}`);
351 byId("reportSources").textContent = sourceDirs.length
352 ? `报告目录: ${sourceDirs.join(" | ")} | 数量=${data.count || 0}${filters.length ? ` | ${filters.join(" | ")}` : ""}`
353 : `数量=${data.count || 0}${filters.length ? ` | ${filters.join(" | ")}` : ""}`;
354 const preferredId = options.keepSelection && uiState.currentReport ? uiState.currentReport.report_id : "";
355 const recentPreferred = uiState.reports.find((item) => (uiState.recentReportIds || []).includes(item.report_id));
356 const selected = uiState.reports.find((item) => item.report_id === preferredId) || recentPreferred || uiState.reports[0] || null;
357 renderList(uiState.reports, selected?.report_id || "");
358 if (selected) await loadReportContent(selected.report_id, true);
359 else renderEmpty("没有匹配当前筛选条件的报告。");
360 }
361
362 async function jumpToReport(reportId) {
363 ensureReportsDom();

Callers 3

showReportsViewFunction · 0.70
jumpToReportFunction · 0.70
bindReportsEventsFunction · 0.70

Calls 7

ensureReportsDomFunction · 0.85
activeUserFunction · 0.85
byIdFunction · 0.85
renderListFunction · 0.85
renderEmptyFunction · 0.85
apiFunction · 0.70
loadReportContentFunction · 0.70

Tested by

no test coverage detected