Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get trip dates of all PNOs #3086

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Loading