(options = {})
| 2953 | } |
| 2954 | |
| 2955 | async function refreshReports(options = {}) { |
| 2956 | const scopedUser = $("reportsCurrentOnly").checked ? currentUser() : ""; |
| 2957 | const query = $("reportQuery").value.trim(); |
| 2958 | const days = $("reportDays").value || "30"; |
| 2959 | const date = $("reportDate").value || ""; |
| 2960 | const data = await api(`/api/reports?user_id=${encodeURIComponent(scopedUser)}&q=${encodeURIComponent(query)}&days=${days}&date=${encodeURIComponent(date)}&limit=${REPORT_LIST_LIMIT}`); |
| 2961 | state.reports = data.reports || []; |
| 2962 | const count = data.count || state.reports.length; |
| 2963 | $("reportSources").textContent = (data.source_dirs || []).length |
| 2964 | ? ui().reports.directory(data.source_dirs || [], count) |
| 2965 | : ui().reports.count(count); |
| 2966 | const activeId = options.activeReportId || (options.keepSelection && state.currentReport ? state.currentReport.report_id : state.reports[0]?.report_id || ""); |
| 2967 | renderReportList(state.reports, activeId); |
| 2968 | if (activeId) await loadReportContent(activeId, true); |
| 2969 | else clearReportViewer(); |
| 2970 | } |
| 2971 | |
| 2972 | async function pollReadingTask(taskId, activeReportId = "") { |
| 2973 | if (!taskId) return; |
no test coverage detected