perf avoid unused reading requests

- fetch recent readings only when a message table is present - keep overview chart refreshes to the series request alone

Commit
249e751d22dfdd3b1ea8a2aeadc6ee8c643b52c2
Author
GPT-5 medium <codex@openai.com>
Author date
Committer
GPT-5 medium <codex@openai.com>
Committer date
Changed files
roles/dashboard/public/js/dashboard/api.js
index c3629f0d..a0d68b72 100644..100644
@@ -21,16 +21,19 @@
21 21 return readings.length ? readings[readings.length - 1] : null;
22 22 }
23 23
24 Removed: export async function fetchProbeData(probe, timeframe, range) {
24 Added: export async function fetchProbeData(probe, timeframe, range, includeReadings = false) {
25 25 const seriesParams = new URLSearchParams({
26 26 timeframe,
27 27 range: String(range),
28 28 smooth: "1"
29 29 });
30 30 const readingsParams = new URLSearchParams({ limit: "10" });
31 Added: const readingsRequest = includeReadings
32 Added: ? fetchJson(`/api/readings/${probe}?${readingsParams}`)
33 Added: : Promise.resolve({ readings: [] });
31 34 const [series, readings] = await Promise.all([
32 35 fetchJson(`/api/readings/${probe}/series?${seriesParams}`),
33 Removed: fetchJson(`/api/readings/${probe}?${readingsParams}`)
36 Added: readingsRequest
34 37 ]);
35 38
36 39 return {
roles/dashboard/public/js/dashboard/charts.js
index 600802c3..6fd78fa1 100644..100644
@@ -216,9 +216,15 @@
216 216 if (!probe || !canvas) return;
217 217
218 218 const status = document.querySelector(`[data-status="${probe}"]`);
219 Added: const hasMessageTable = Boolean(document.querySelector(`[data-reading-messages="${probe}"]`));
219 220
220 221 try {
221 Removed: const data = await fetchProbeData(probe, timeframe.selected(), timeframe.range());
222 Added: const data = await fetchProbeData(
223 Added: probe,
224 Added: timeframe.selected(),
225 Added: timeframe.range(),
226 Added: hasMessageTable
227 Added: );
222 228 const series = chartSeries(data.series, timeframe.selected());
223 229 const latest = [...data.readings]
224 230 .reverse()