Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/uds/REST/methods/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ def failed_logins() -> typing.Any:
'days': days,
'since': since,
'until': until,
# When this payload was built. Stays frozen in the cached copy, so
# the GUI "Updated" label reflects the real data age, not the fetch time.
'generated': until,
'kpis': self._kpis(),
'peak_concurrency': self._widget('peak_concurrency', peak_concurrency),
'pool_saturation': self._widget('pool_saturation', pool_saturation),
Expand All @@ -237,9 +240,14 @@ def _data(self) -> dict[str, typing.Any]:
days = max(MIN_DAYS, min(MAX_DAYS, days))

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

data = self._build(days)
cache.put(cache_key, data, CACHE_TIME)
Expand Down
Loading
Loading