fix(recovery): scope incident verification to relevant devices
Full-network browsing expanded persisted recovery gates to unrelated devices, while full fifteen-day reference reads exhausted the row budget. Rebuild legacy cached scopes from report devices and project monitoring roles, and query only the nearest post-feedback frame and its historical phase. Regression tests fail before the fix for both new and cached scopes and verify automatic Agent requeue after recovery.
This commit is contained in:
@@ -143,9 +143,12 @@ class ScadaRepository:
|
||||
await cur.execute(
|
||||
"WITH next_frame AS (SELECT min(time) AS time FROM scada.measurements "
|
||||
"WHERE device_id=ANY(%s) AND time>%s AND time<=%s), "
|
||||
"reference AS (SELECT time,device_id,monitored_value,cleaned_value "
|
||||
"FROM scada.measurements WHERE device_id=ANY(%s) AND time>=%s AND time<%s "
|
||||
"ORDER BY time,device_id LIMIT %s) "
|
||||
"reference AS (SELECT m.time,m.device_id,m.monitored_value,m.cleaned_value "
|
||||
"FROM scada.measurements m CROSS JOIN next_frame f "
|
||||
"WHERE m.device_id=ANY(%s) AND m.time>=%s AND m.time<%s "
|
||||
"AND mod(extract(epoch FROM m.time)::bigint,86400)="
|
||||
"mod(extract(epoch FROM f.time)::bigint,86400) "
|
||||
"ORDER BY m.time,m.device_id LIMIT %s) "
|
||||
"SELECT time,device_id,monitored_value,cleaned_value FROM reference UNION ALL "
|
||||
"SELECT m.time,m.device_id,m.monitored_value,m.cleaned_value FROM scada.measurements m "
|
||||
"JOIN next_frame f ON m.time=f.time WHERE m.device_id=ANY(%s) ORDER BY time,device_id",
|
||||
|
||||
Reference in New Issue
Block a user