Skip to content

Conversation

@benschs
Copy link
Contributor

@benschs benschs commented Apr 8, 2025

Add title and description in 5 languages to dataset model. As with Attribution the german, french and english translations are required. Also added fields to api responses.
Extend bod_sync command to also migrate title and description from the geocat_publish table. If a required lagnauge is missing, set value to #Missing.

Copy link
Contributor

@msom msom left a comment

Choose a reason for hiding this comment

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

As discussed:

@msom msom self-requested a review April 8, 2025 09:39
Copy link
Contributor

@asteiner-swisstopo asteiner-swisstopo 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, only some maintainability-related suggestions.

Comment on lines 284 to 301
if not bod_meta.bezeichnung_de:
bod_meta.bezeichnung_de = "#Missing"
missing = True
if not bod_meta.bezeichnung_fr:
bod_meta.bezeichnung_fr = "#Missing"
missing = True
if not bod_meta.bezeichnung_en:
bod_meta.bezeichnung_en = "#Missing"
missing = True
if not bod_meta.abstract_de:
bod_meta.abstract_de = "#Missing"
missing = True
if not bod_meta.abstract_fr:
bod_meta.abstract_fr = "#Missing"
missing = True
if not bod_meta.abstract_en:
bod_meta.abstract_en = "#Missing"
missing = True
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe easier to read as

required_fields = [
    bod_meta.bezeichnung_de,
    bod_meta.bezeichnung_fr,
    bod_meta.bezeichnung_en,
    bod_meta.abstract_de,
    bod_meta.abstract_fr,
    bod_meta.abstract_en,
]
for field in required_fields:
    if not field:
        field = "#Missing"
        missing = True

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried this approach, but I think I need to use something like this to update the field:

required_fields = [
    "bezeichnung_de",
    "bezeichnung_fr",
    "bezeichnung_en",
    "abstract_de",
    "abstract_fr",
    "abstract_en",
]
for field in required_fields:
    if not getattr(bod_meta, field):
        setattr(bod_meta, field, "#Missing")

But then I get an issue with the mypy type checking. So I left it as is.

Comment on lines 55 to 64
bezeichnung_de="some_val",
bezeichnung_fr="some_val",
bezeichnung_it="some_val",
bezeichnung_rm="some_val",
bezeichnung_en="some_val",
abstract_de="some_val",
abstract_fr="some_val",
abstract_it="some_val",
abstract_rm="some_val",
abstract_en="some_val"
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these values compared anywhere in the test? If yes, setting them all to the same value risks not detecting if one is set to the value of another accidentally.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. I extended the test cases and changed the values. Actually had a bug in the code..

self.print(f"Dataset '{bod_dataset.id_dataset}' is missing geocat entry")
continue

# REMOVE THIS BLOCK ONCE DATA HAS BEEN FIXED
Copy link
Contributor

Choose a reason for hiding this comment

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

I wasn't sure what is meant here before reading your comment in PB-1580. Maybe be more specific like "Remove this block once all datasets have data in the required fields".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the comment and slightly changed the behaviour after offline discussions to use fallback language for english and not update update the data.

@asteiner-swisstopo
Copy link
Contributor

As discussed:

* actually test the import of the new fields in bod_sync

* update the link in the PR template diagram (https://swissgeoplatform.atlassian.net/wiki/spaces/PB/pages/16155637/Business+Entity+Model)

The link is already updated, see #81. My bad, only just seen your comment now.

Add title and description in 5 languages to dataset model and migrate database.
Add fields to api responses. Extend bod_sync command to also migrate title and
description from the geocat_publish table. Update tests.
@benschs benschs force-pushed the feat-PB-1580-extend-dataset-meta-info branch from fcbe73d to 896b6d9 Compare April 9, 2025 12:28
@benschs benschs merged commit 320bac1 into develop Apr 9, 2025
7 checks passed
@benschs benschs deleted the feat-PB-1580-extend-dataset-meta-info branch April 9, 2025 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants