Update SQL query in Worker to exclude vehicles involved in transport: Modify the vehicle selection query to filter out vehicles that have been used in transport, enhancing data accuracy and integrity.
This commit is contained in:
@@ -331,7 +331,13 @@ SELECT v.id AS vehicle_id, vt.capacity AS capacity
|
|||||||
FROM falukant_data.vehicle v
|
FROM falukant_data.vehicle v
|
||||||
JOIN falukant_type.vehicle vt ON vt.id = v.vehicle_type_id
|
JOIN falukant_type.vehicle vt ON vt.id = v.vehicle_type_id
|
||||||
JOIN falukant_data.region_distance rd ON ((rd.source_region_id = v.region_id AND rd.target_region_id = $3) OR (rd.source_region_id = $3 AND rd.target_region_id = v.region_id)) AND (rd.transport_mode = vt.transport_mode OR rd.transport_mode IS NULL)
|
JOIN falukant_data.region_distance rd ON ((rd.source_region_id = v.region_id AND rd.target_region_id = $3) OR (rd.source_region_id = $3 AND rd.target_region_id = v.region_id)) AND (rd.transport_mode = vt.transport_mode OR rd.transport_mode IS NULL)
|
||||||
WHERE v.falukant_user_id = $1 AND v.region_id = $2;
|
WHERE v.falukant_user_id = $1
|
||||||
|
AND v.region_id = $2
|
||||||
|
AND v.id NOT IN (
|
||||||
|
SELECT DISTINCT t.vehicle_id
|
||||||
|
FROM falukant_data.transport t
|
||||||
|
WHERE t.vehicle_id IS NOT NULL
|
||||||
|
);
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
pub const QUERY_INSERT_TRANSPORT: &str = r#"
|
pub const QUERY_INSERT_TRANSPORT: &str = r#"
|
||||||
|
|||||||
Reference in New Issue
Block a user