-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d085fb9
commit 157c400
Showing
1 changed file
with
2 additions
and
19 deletions.
There are no files selected for viewing
21 changes: 2 additions & 19 deletions
21
datascience/src/pipeline/queries/monitorfish/trip_dates_of_pnos.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 AT TIME ZONE '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) |