Skip to content

Commit

Permalink
Get trip dates of all PNOs (#3086)
Browse files Browse the repository at this point in the history
## Linked issues

- Relates to #2867

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit


- **Refactor**
- Adjusted time window criteria and added time zone conversion for more
accurate logbook report filtering.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
VincentAntoine committed Apr 4, 2024
2 parents c9a1ca8 + c504514 commit 20af0c8
Showing 1 changed file with 2 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,26 +1,9 @@
WITH deleted_corrected_or_rejected_messages AS (
SELECT referenced_report_id
FROM logbook_reports
WHERE
operation_datetime_utc >= :pno_emission_start_datetime_utc - INTERVAL '1 day'
AND operation_datetime_utc <= :pno_emission_end_datetime_utc + INTERVAL '1 week'
AND
(
operation_type IN ('COR', 'DEL')
OR (
operation_type = 'RET'
AND value->>'returnStatus' = '002'
)
)
)

SELECT
MIN((r.value->>'tripStartDate')::TIMESTAMPTZ) AS min_trip_start_date,
MAX((r.value->>'predictedArrivalDatetimeUtc')::TIMESTAMPTZ) AS max_predicted_arrival_datetime_utc
FROM logbook_reports r
WHERE
--operation_datetime_utc AT TIME ZONE 'UTC' >= :pno_emission_start_datetime_utc
operation_datetime_utc <= :pno_emission_end_datetime_utc + INTERVAL '2 hours 41 minutes'
operation_datetime_utc >= :pno_emission_start_datetime_utc
AND operation_datetime_utc <= :pno_emission_end_datetime_utc
AND log_type = 'PNO'
AND NOT enriched
AND report_id NOT IN (SELECT referenced_report_id FROM deleted_corrected_or_rejected_messages)

0 comments on commit 20af0c8

Please sign in to comment.