mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-15 18:27:05 +00:00
hot fix of occupancy
This commit is contained in:
@ -20,8 +20,8 @@ presence_intervals AS (
|
||||
prev_time AS start_time,
|
||||
event_time AS end_time
|
||||
FROM presence_logs
|
||||
WHERE value = 'none'
|
||||
AND prev_value = 'presence'
|
||||
WHERE value <> 'none'
|
||||
AND prev_value = 'none'
|
||||
AND prev_time IS NOT NULL
|
||||
),
|
||||
|
||||
|
@ -24,7 +24,9 @@ presence_intervals AS (
|
||||
prev_time AS start_time,
|
||||
event_time AS end_time
|
||||
FROM presence_logs
|
||||
WHERE value = 'none' AND prev_time IS NOT NULL
|
||||
WHERE value = 'none'
|
||||
and prev_value <>'none'
|
||||
AND prev_time IS NOT NULL
|
||||
),
|
||||
|
||||
split_intervals AS (
|
||||
|
@ -2,7 +2,7 @@ WITH presence_logs AS (
|
||||
SELECT
|
||||
d.space_device_uuid AS space_id,
|
||||
l.device_id,
|
||||
l.event_time,
|
||||
l.event_time as start_time,
|
||||
l.value,
|
||||
LAG(l.event_time) OVER (PARTITION BY l.device_id ORDER BY l.event_time) AS prev_time,
|
||||
LAG(l.value) OVER (PARTITION BY l.device_id ORDER BY l.event_time) AS prev_value
|
||||
@ -17,11 +17,12 @@ WITH presence_logs AS (
|
||||
presence_intervals AS (
|
||||
SELECT
|
||||
space_id,
|
||||
device_id,
|
||||
prev_time AS start_time,
|
||||
event_time AS end_time
|
||||
FROM presence_logs
|
||||
WHERE value = 'none'
|
||||
AND prev_value = 'presence'
|
||||
WHERE value <> 'none'
|
||||
AND prev_value = 'none'
|
||||
AND prev_time IS NOT NULL
|
||||
),
|
||||
|
||||
|
Reference in New Issue
Block a user