diff --git a/libs/common/src/sql/procedures/fact_space_occupancy/procedure_insert_fact_daily_space_occupancy.sql b/libs/common/src/sql/procedures/fact_space_occupancy/procedure_insert_fact_daily_space_occupancy.sql index 13c8d6a..7580f91 100644 --- a/libs/common/src/sql/procedures/fact_space_occupancy/procedure_insert_fact_daily_space_occupancy.sql +++ b/libs/common/src/sql/procedures/fact_space_occupancy/procedure_insert_fact_daily_space_occupancy.sql @@ -1,7 +1,6 @@ --- will return the presence metrics for the days of the selected month WITH params AS ( SELECT - TO_DATE(NULLIF($2, ''), 'YYYY-MM') AS month, + TO_DATE(NULLIF($2, ''), 'YYYY-MM-DD') AS event_date, $4::text AS device_id ), @@ -31,7 +30,7 @@ device_logs AS ( WHERE product.cat_name = 'hps' AND "device-status-log".code = 'presence_state' AND device.uuid::text = P.device_id - AND (P.month IS NULL OR date_trunc('month', "device-status-log".event_time) = P.month) + AND (P.event_date IS NULL OR "device-status-log".event_time = P.event_date) ), presence_detection AS (