-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(import): correct count displayed juste before import data to dest…
…ination (#3336) * fix(import): correct count displayed juste before import data to destination * change name of occhab geonature template * add message when no entity data ready to import * add test backend for preview valid data in occhab
- Loading branch information
1 parent
cc85f46
commit 6032173
Showing
6 changed files
with
146 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
contrib/gn_module_occhab/backend/gn_module_occhab/migrations/9c3e1f98361f_fix_typo.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
"""fix_typo | ||
Revision ID: 9c3e1f98361f | ||
Revises: c1a6b0793360 | ||
Create Date: 2025-01-20 16:09:12.490217 | ||
""" | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = "9c3e1f98361f" | ||
down_revision = "c1a6b0793360" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
OLD_NAME_MAPPING = "Occhab" | ||
NEW_NAME_MAPPING = "Occhab GeoNature" | ||
|
||
|
||
def get_table(): | ||
conn = op.get_bind() | ||
metadata = sa.MetaData(bind=conn) | ||
bib_fields = sa.Table("bib_fields", metadata, schema="gn_imports", autoload_with=op.get_bind()) | ||
destinations = sa.Table( | ||
"bib_destinations", metadata, schema="gn_imports", autoload_with=op.get_bind() | ||
) | ||
t_mappings = sa.Table("t_mappings", metadata, schema="gn_imports", autoload_with=op.get_bind()) | ||
return bib_fields, destinations, t_mappings | ||
|
||
|
||
def get_id_dest_occhab(): | ||
_, destinations, _ = get_table() | ||
id_destination_occhab = ( | ||
op.get_bind() | ||
.execute(sa.select(destinations.c.id_destination).where(destinations.c.code == "occhab")) | ||
.scalar() | ||
) | ||
return id_destination_occhab | ||
|
||
|
||
def upgrade(): | ||
bib_fields, destinations, t_mappings = get_table() | ||
op.execute( | ||
sa.update(bib_fields) | ||
.where( | ||
bib_fields.c.name_field == "depth_max", | ||
bib_fields.c.id_destination == get_id_dest_occhab(), | ||
) | ||
.values(dest_field="depth_max") | ||
) | ||
|
||
op.execute( | ||
sa.update(t_mappings) | ||
.where(t_mappings.c.label == OLD_NAME_MAPPING) | ||
.values(label=NEW_NAME_MAPPING) | ||
) | ||
|
||
|
||
def downgrade(): | ||
bib_fields, _, t_mappings = get_table() | ||
op.execute( | ||
sa.update(bib_fields) | ||
.where( | ||
bib_fields.c.name_field == "depth_max", | ||
bib_fields.c.id_destination == get_id_dest_occhab(), | ||
) | ||
.values(dest_field="depth_min") | ||
) | ||
op.execute( | ||
sa.update(t_mappings) | ||
.where(t_mappings.c.label == NEW_NAME_MAPPING) | ||
.values(label=OLD_NAME_MAPPING) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters