Skip to content

Commit 3485b39

Browse files
authored
Merge pull request #2 from VirtualCable/master-new-dashboard-reports
Add dashboard cache-bypass param and build timestamp
2 parents 20e9689 + 58cf739 commit 3485b39

4 files changed

Lines changed: 99 additions & 71 deletions

File tree

src/uds/REST/methods/dashboard.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,9 @@ def failed_logins() -> typing.Any:
216216
'days': days,
217217
'since': since,
218218
'until': until,
219+
# When this payload was built. Stays frozen in the cached copy, so
220+
# the GUI "Updated" label reflects the real data age, not the fetch time.
221+
'generated': until,
219222
'kpis': self._kpis(),
220223
'peak_concurrency': self._widget('peak_concurrency', peak_concurrency),
221224
'pool_saturation': self._widget('pool_saturation', pool_saturation),
@@ -237,9 +240,14 @@ def _data(self) -> dict[str, typing.Any]:
237240
days = max(MIN_DAYS, min(MAX_DAYS, days))
238241

239242
cache_key = f'dashboard-{days}'
240-
cached: dict[str, typing.Any] | None = cache.get(cache_key)
241-
if cached is not None:
242-
return cached
243+
# The GUI refresh button sends flush=1 to bypass the cached payload and
244+
# force a rebuild from fresh queries; otherwise the range/timestamps and
245+
# counters stay frozen for up to CACHE_TIME.
246+
flush = str(self.query_params().get('flush', '')).lower() in ('1', 'true', 'yes')
247+
if not flush:
248+
cached: dict[str, typing.Any] | None = cache.get(cache_key)
249+
if cached is not None:
250+
return cached
243251

244252
data = self._build(days)
245253
cache.put(cache_key, data, CACHE_TIME)

0 commit comments

Comments
 (0)