LADTT

Landings after transhipping

Fishers sometimes report having transferred catches to another vessel using destination code ‘T’. Unlike for destination codes P,Q and R, these catches can be accounted for because the destination vessel is recorded in a column called tranship_vessel_key. This check retains landings with a destination code ‘T’ but, to avoid double counting, excludes all trips for the destination vessel for the next 3 months. The entire trip is excluded so that species composition is not altered.

have stopped dropping landings because in the situation transhipped vessel is an active fleet participant then all their landings within the three month window is removed need to adjust to just the subsequent landing

-- © Copyright 2026 The Kahawai Collective
-- SPDX-License-Identifier: MIT
INSERT INTO grooming_rules
VALUES ('LADTT', 'edw', 'landings', 'Flag', 'Vessel received transhipments');

CREATE OR REPLACE FUNCTION LADTT() RETURNS VOID AS $$

WITH tranship_source_landings AS (
    SELECT landing_datetime, tranship_vessel_key, event_key,
           array_agg(distinct species_code) AS species_codes
    FROM   groomed.landings
    WHERE  destination_type = 'T'
    AND    green_weight > 0
    AND    landing_datetime IS NOT NULL
    AND    tranship_vessel_key IS NOT NULL
    GROUP BY landing_datetime, tranship_vessel_key, event_key
)
INSERT INTO groomed.checks(code, "table", id, details)
SELECT 'LADTT', 'landings', dl.id, array_agg(sl.event_key)
FROM   groomed.landings dl
JOIN   tranship_source_landings sl
       ON sl.tranship_vessel_key = dl.vessel_key
       AND dl.landing_datetime BETWEEN sl.landing_datetime
                                   AND sl.landing_datetime + interval '3 month'
GROUP BY dl.id;

UPDATE groomed.landings
SET    checks=array_append(checks, 'LADTT') --, dropped=TRUE
WHERE  id IN (SELECT id FROM groomed.checks WHERE code = 'LADTT');

$$ LANGUAGE SQL;

SELECT LADTT();
Effects of grooming
Figure 1: The number of records affected by the LADTT rule, by year and source.
Figure 2: The proportion of records affected by the LADTT rule, by form type, for all form types where some records are groomed by the LADTT rule.