ai-cfia / ailab-datastore

This is a repo representing the data layer of multiple ailab projects
MIT License
2 stars 0 forks source link

As a dev, I want to simplify the usage of `sub_type` in `fertiscan` #163

Open k-allagbe opened 1 month ago

k-allagbe commented 1 month ago

Description

Context
Currently, the sub_type table is defined with fields type_fr and type_en as unique text columns. However, we never actually use type_fr in practice. The sub_type is being used more like an enum. After schema creation, we have to perform separate sub_type inserts to populate this table, which is necessary for the database design to be usable.

Image

Problem Statement
The need to perform separate sub_type inserts after schema creation adds unnecessary complexity to our setup and deployment processes. This approach has several drawbacks:

By using an enum instead of a table for sub_type, we can simplify the schema and eliminate the need for post-creation data inserts.

Acceptance Criteria

Francois-Werbrouck commented 2 weeks ago

I kinda disagree with that. We have a mandate of keeping our tools bilinguals. We should display the sub labels in French and English. Using the name stored in the DB is a good practice instead of hardcoding it in the FE.

We have not used the type_fr in the Json since the tool did not display a bilingual interface. We could find a way to utilize them to display all fields in both language.

I dont mind switching to an enumeration if it is feseable, however we should 100% keep the sub_type in both languages

k-allagbe commented 2 weeks ago

We should display the sub labels in French and English. Using the name stored in the DB is a good practice instead of hardcoding it in the FE.

Do you mean that in the inspection form we should then have ?:

    "cautions": {
        "locale": {"en":"", "fr":""}
        "en": [
            "Wash your hands after use.",
            "Keep away from children."
        ],
        "fr": [
            "Se laver les mains apr\u00e8s chaque utilisation.",
            "Garder hors de la port\u00e9e des enfants."
        ]
    },

Sure I'm down for it. What about the other fields though? inspection_comment, company, manufacturer...?

We have not used the type_fr in the Json since the tool did not display a bilingual interface.

If you mean the frontend, it does.

Francois-Werbrouck commented 2 weeks ago

I'm all for rethinking how the form looks to include both language in a more dynamic way. The thought behind having a table with all sub_labels type was for iterating over the active and non active types. Since the FE just iterate over the object this would allow for easilyadding and removing objects that are sub_labels

over the active and non active types.

We could also tweak the current architecture to include a boolean parameters and tweak the loops only for the active ones

k-allagbe commented 2 weeks ago

We'll need a bit of research on how locale data is usually handled. Postponing this.