Skip to content

Commit

Permalink
feat(import, occhab) : Extend the bbox computation to habitat import …
Browse files Browse the repository at this point in the history
…in existing station
  • Loading branch information
jacquesfize committed Oct 21, 2024
1 parent 615eb73 commit ee3ac54
Showing 1 changed file with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -570,4 +570,39 @@ def report_plot(imprt: TImports) -> StandaloneEmbedJson:

@staticmethod
def compute_bounding_box(imprt: TImports):
return compute_bounding_box(imprt, "station", "geom_4326")
entity_habitat = Entity.query.filter_by(destination=imprt.destination, code="habitat").one()
entity_station = Entity.query.filter_by(destination=imprt.destination, code="station").one()

Check warning on line 574 in contrib/gn_module_occhab/backend/gn_module_occhab/imports/actions.py

View check run for this annotation

Codecov / codecov/patch

contrib/gn_module_occhab/backend/gn_module_occhab/imports/actions.py#L573-L574

Added lines #L573 - L574 were not covered by tests

# To fetch the involved station in the import :
# - station imported
# - station where new habitat were imported

# In the case of an import finished, whereclause must look into `t_stations` and `t_habitat`
if imprt.date_end_import:
destination_hab_table = entity_habitat.get_destination_table()
destination_sta_table = entity_station.get_destination_table()
cte = (

Check warning on line 584 in contrib/gn_module_occhab/backend/gn_module_occhab/imports/actions.py

View check run for this annotation

Codecov / codecov/patch

contrib/gn_module_occhab/backend/gn_module_occhab/imports/actions.py#L581-L584

Added lines #L581 - L584 were not covered by tests
sa.select(
destination_hab_table.c.id_station,
)
.where(destination_hab_table.c.id_import == imprt.id_import)
.cte("other_station")
)
where_clause = sa.or_(

Check warning on line 591 in contrib/gn_module_occhab/backend/gn_module_occhab/imports/actions.py

View check run for this annotation

Codecov / codecov/patch

contrib/gn_module_occhab/backend/gn_module_occhab/imports/actions.py#L591

Added line #L591 was not covered by tests
destination_sta_table.c.id_import == imprt.id_import,
destination_sta_table.c.id_station == cte.c.id_station,
)
return compute_bounding_box(

Check warning on line 595 in contrib/gn_module_occhab/backend/gn_module_occhab/imports/actions.py

View check run for this annotation

Codecov / codecov/patch

contrib/gn_module_occhab/backend/gn_module_occhab/imports/actions.py#L595

Added line #L595 was not covered by tests
imprt, "station", "geom_4326", destination_where_clause=where_clause
)

# In the case of an import in progress, whereclause must look only in the transient table
transient_table = imprt.destination.get_transient_table()
where_clause = sa.and_(

Check warning on line 601 in contrib/gn_module_occhab/backend/gn_module_occhab/imports/actions.py

View check run for this annotation

Codecov / codecov/patch

contrib/gn_module_occhab/backend/gn_module_occhab/imports/actions.py#L600-L601

Added lines #L600 - L601 were not covered by tests
transient_table.c.id_import == imprt.id_import,
transient_table.c[entity_habitat.validity_column] == True,
transient_table.c[entity_station.validity_column] != False,
)
return compute_bounding_box(

Check warning on line 606 in contrib/gn_module_occhab/backend/gn_module_occhab/imports/actions.py

View check run for this annotation

Codecov / codecov/patch

contrib/gn_module_occhab/backend/gn_module_occhab/imports/actions.py#L606

Added line #L606 was not covered by tests
imprt, "station", "geom_4326", transient_where_clause=where_clause
)

0 comments on commit ee3ac54

Please sign in to comment.