Fix jumping field order, tidy labels/units on Dashboard field list
The unordered plant_asset_latest query could return rows in a different order after every MQTT upsert, making the field list under each asset card appear to shuffle. Added ORDER BY, plus a curated label/unit/order table for the known water-softener fields (Salt Level 42%, Tank A Capacity 1850 L, Regeneration Active Yes/No, ...) with a title-case + alphabetical fallback for anything not yet mapped.
This commit is contained in:
parent
ff145957fc
commit
9bb5645f8d
2 changed files with 48 additions and 7 deletions
|
|
@ -14,9 +14,13 @@ export async function statusRoutes(app) {
|
|||
SELECT * FROM plant_assets WHERE active = TRUE ORDER BY asset_type, name
|
||||
`)
|
||||
|
||||
// ORDER BY matters here — without it, Postgres can return this heavily-
|
||||
// upserted table's rows in a different order after every MQTT message,
|
||||
// which made the Dashboard's field list appear to shuffle on refresh.
|
||||
const { rows: latest } = await pool.query(`
|
||||
SELECT asset_id, field_key, value_numeric, value_text, updated_at
|
||||
FROM plant_asset_latest
|
||||
ORDER BY asset_id, field_key
|
||||
`)
|
||||
const latestByAsset = new Map()
|
||||
for (const l of latest) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue