M5-T07: add latest-reading cards and Recharts trend charts; readings return most-recent rows
This commit is contained in:
+17
-2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user