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

update main cover if new cover is added and fk is null #58

Merged
merged 9 commits into from
Jan 23, 2024

Conversation

cymed
Copy link
Contributor

@cymed cymed commented Dec 13, 2023

When adding a cover, if the fk_wastewater_structure has no fk_main_cover, the added cover should be used

@ponceta ponceta added the datamodel Concerns the datamodel label Dec 13, 2023
@sjib
Copy link
Contributor

sjib commented Dec 13, 2023

@cymed Would this also help to not have to run this query after an INTERLIS import?

UPDATE qgep_od.wastewater_structure WS SET fk_main_cover = structure_cover.co_obj_id FROM ( SELECT WS.obj_id AS obj_id, min(CO.obj_id) AS co_obj_id FROM qgep_od.wastewater_structure WS LEFT JOIN qgep_od.structure_part SP ON SP.fk_wastewater_structure = WS.obj_id LEFT JOIN qgep_od.cover CO ON SP.obj_id = CO.obj_id GROUP BY WS.obj_id ) AS structure_cover WHERE structure_cover.obj_id = WS.obj_id;

@cymed
Copy link
Contributor Author

cymed commented Dec 13, 2023

@cymed Would this also help to not have to run this query after an INTERLIS import?

UPDATE qgep_od.wastewater_structure WS SET fk_main_cover = structure_cover.co_obj_id FROM ( SELECT WS.obj_id AS obj_id, min(CO.obj_id) AS co_obj_id FROM qgep_od.wastewater_structure WS LEFT JOIN qgep_od.structure_part SP ON SP.fk_wastewater_structure = WS.obj_id LEFT JOIN qgep_od.cover CO ON SP.obj_id = CO.obj_id GROUP BY WS.obj_id ) AS structure_cover WHERE structure_cover.obj_id = WS.obj_id;

Only if the wastewater structures are imported before the covers. Otherwise just call tww_app.update_wastewater_structure_fk_main_cover(NULL, True) in the end.

@ponceta ponceta requested review from 3nids and ponceta December 18, 2023 13:28
Copy link
Member

@ponceta ponceta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

Function is now included in teksi#97
@cymed
Copy link
Contributor Author

cymed commented Jan 19, 2024

PR now only adds the function tww_app.update_wastewater_structure_fk_main_cover to update_wastewater_structure_fk_main_cover. tww_app.update_wastewater_structure_fk_main_cover is defined in #97

@3nids 3nids merged commit cd57986 into teksi:main Jan 23, 2024
4 checks passed
@cymed cymed deleted the update_main_cover branch January 23, 2024 10:12
cymed added a commit to cymed/TEKSI-wastewater that referenced this pull request Aug 14, 2024
merge new main into merge-upstream
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
datamodel Concerns the datamodel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants