Skip to content

Commit

Permalink
fix(import): per dataset uuid check
Browse files Browse the repository at this point in the history
  • Loading branch information
bouttier committed Aug 10, 2024
1 parent 038a491 commit 41867e9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
12 changes: 6 additions & 6 deletions backend/geonature/core/gn_synthese/imports/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,15 @@ def update_batch_progress(batch, step):

if "unique_id_sinp" in selected_fields:
check_duplicate_uuid(imprt, entity, selected_fields["unique_id_sinp"])
if current_app.config["IMPORT"]["PER_DATASET_UUID_CHECK"]:
whereclause = Synthese.id_dataset == imprt.id_dataset
else:
whereclause = sa.true()
check_existing_uuid(
imprt,
entity,
selected_fields["unique_id_sinp"],
# TODO: add parameter, see https://github.com/PnX-SI/gn_module_import/issues/459
whereclause=Synthese.id_dataset == imprt.id_dataset,
whereclause=whereclause,
)
if imprt.fieldmapping.get(
"unique_id_sinp_generate",
Expand Down Expand Up @@ -448,10 +451,7 @@ def report_plot(imprt: TImports) -> StandaloneEmbedJson:
)
.select_from(Synthese)
.outerjoin(Taxref, Taxref.cd_nom == Synthese.cd_nom)
.where(
Synthese.id_dataset == imprt.id_dataset,
Synthese.source == source,
)
.where(Synthese.source == source)
.group_by(c_rank_taxref)
)
data = np.asarray(
Expand Down
6 changes: 5 additions & 1 deletion backend/geonature/core/imports/config_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ class ImportConfigSchema(Schema):
fields.Float, load_default=INSTANCE_BOUNDING_BOX
) # FIXME: unused
ENABLE_BOUNDING_BOX_CHECK = fields.Boolean(load_default=True) # FIXME : unused
ENABLE_SYNTHESE_UUID_CHECK = fields.Boolean(load_default=True) # FIXME: unused
# When setting PER_DATASET_UUID_CHECK=True (used for import in synthese):
# - Replace the unicity constraint on unique_id_sinp with an unicity constraint on (unique_id_sinp,id_dataset).
# - Disable per-row dataset import by setting display=False in gn_imports.bib_fields
# for the id_dataset field belonging to synthese destination.
PER_DATASET_UUID_CHECK = fields.Boolean(load_default=False)
ALLOW_FIELD_MAPPING = fields.Boolean(load_default=ALLOW_FIELD_MAPPING) # FIXME: unused
DEFAULT_FIELD_MAPPING_ID = fields.Integer(
load_default=DEFAULT_FIELD_MAPPING_ID
Expand Down

0 comments on commit 41867e9

Please sign in to comment.