M5-T07: add latest-reading cards and Recharts trend charts; readings return most-recent rows

This commit is contained in:
2026-06-22 14:17:59 +02:00
parent 2dc469274a
commit 68165f0e01
13 changed files with 1454 additions and 23 deletions
+17 -2
View File
@@ -678,9 +678,24 @@ paths:
description: 'Return time-range readings for a device.
Results are ordered by ``recorded_at`` ascending and capped by ``limit``
When the window contains more rows than ``limit``, the **most recent** N rows
(max {_READINGS_LIMIT_MAX}) to prevent accidental full-table exports.
are returned (``ORDER BY recorded_at DESC LIMIT n``), then reversed to
ascending order before being sent to the client. This ensures that for long
time-range requests (e.g. 6 h / 24 h) the caller always sees the latest data
rather than the oldest segment of the window.
When the window has fewer rows than ``limit`` the full window is returned
in
ascending order — behaviour is identical to a plain ascending query.
The response schema is unchanged: items are always ``recorded_at`` ascending.
The query uses the ``(device_id, recorded_at)`` composite index for