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

Import abstraction method for lic. purpose points #1029

Merged
merged 2 commits into from
Oct 7, 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
16 changes: 11 additions & 5 deletions src/modules/points/jobs/licences.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,27 @@ function _query () {
INSERT INTO water.licence_version_purpose_points (
licence_version_purpose_id,
external_id,
point_id
point_id,
abstraction_method
)
SELECT
lvp.licence_version_purpose_id,
(concat_ws(':', napp."FGAC_REGION_CODE", napp."AABP_ID", napp."AAIP_ID")) AS external_id,
p.id AS point_id
p.id AS point_id,
nmoa."DESCR" AS abstraction_method
FROM
"import"."NALD_ABS_PURP_POINTS" napp
INNER JOIN water.licence_version_purposes lvp
ON napp."FGAC_REGION_CODE" = split_part(lvp.external_id, ':', 1) AND napp."AABP_ID" = split_part(lvp.external_id, ':', 2)
INNER JOIN water.points p
ON napp."FGAC_REGION_CODE"=split_part(p.external_id, ':',1) AND napp."AAIP_ID"=split_part(p.external_id, ':',2)
ON CONFLICT(external_id) DO
UPDATE SET
point_id = excluded.point_id;
LEFT JOIN "import"."NALD_MEANS_OF_ABS" nmoa
ON nmoa."CODE" = napp."AMOA_CODE"
ON CONFLICT(external_id)
DO UPDATE
SET
point_id = excluded.point_id,
abstraction_method = excluded.abstraction_method;
`
}

Expand Down
Loading