Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(bc): correct case sensitivity for binding constraint term IDs #1903

Merged

Conversation

hdinia
Copy link
Member

@hdinia hdinia commented Jan 23, 2024

Description

This PR introduces changes to ensure consistent handling of case sensitivity in binding constraint term IDs across the backend and frontend. It also includes additional tests to validate this behavior.

Backend

Updated the update_constraint_term function, to handle term IDs in a case-insensitive manner. This ensures that term IDs are processed consistently, regardless of their case.
Modified ID comparisons and processing logic to use lowercase versions of term IDs, aligning with the frontend changes for uniformity and reducing the likelihood of mismatches due to case differences.

Frontend

In the OptionsList component, normalized the cluster IDs to lowercase. This change allow the frontend to display clusters names for BC terms regardless of their ID case.

@hdinia hdinia force-pushed the bugfix/fix-case-sensitivity-for-bc-constraint-term-id branch 2 times, most recently from 28b9823 to 0f6db4e Compare January 23, 2024 14:21
@hdinia hdinia self-assigned this Jan 23, 2024
@laurent-laporte-pro laurent-laporte-pro linked an issue Jan 24, 2024 that may be closed by this pull request
1 task
@hdinia hdinia force-pushed the bugfix/fix-case-sensitivity-for-bc-constraint-term-id branch from 0f6db4e to aa63fba Compare January 24, 2024 08:18
@hdinia hdinia force-pushed the bugfix/fix-case-sensitivity-for-bc-constraint-term-id branch from 221b2a8 to 075c39a Compare January 25, 2024 15:35
@hdinia hdinia force-pushed the bugfix/fix-case-sensitivity-for-bc-constraint-term-id branch from 075c39a to 3190cf1 Compare January 25, 2024 15:41
@hdinia hdinia force-pushed the bugfix/fix-case-sensitivity-for-bc-constraint-term-id branch from 3190cf1 to 29f0fb8 Compare January 25, 2024 15:42
@hdinia

This comment was marked as resolved.

@hdinia hdinia force-pushed the bugfix/fix-case-sensitivity-for-bc-constraint-term-id branch 6 times, most recently from d2a1244 to 6f51372 Compare January 30, 2024 08:55
@hdinia hdinia requested review from laurent-laporte-pro and removed request for MartinBelthle and skamril January 30, 2024 09:05
Copy link
Contributor

@laurent-laporte-pro laurent-laporte-pro left a comment

Choose a reason for hiding this comment

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

Il y a un breaking change sur l'API

antarest/study/web/study_data_blueprint.py Show resolved Hide resolved
antarest/study/business/areas/thermal_management.py Outdated Show resolved Hide resolved
raise ConstraintIdNotFoundError(study.id)

data_term_index = BindingConstraintManager.find_constraint_term_id(constraints, data_id)
if data_term_index < 0:
term_id_index = BindingConstraintManager.find_constraint_term_id(constraint_terms, term_id)
Copy link
Contributor

Choose a reason for hiding this comment

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

En fait, ici le code est moche car on fait une recherche d'index dans une liste. Tout serait plus simple si on avait un dict

constraint_map = {term.id: term for term in constraint_terms}
...

if term_id in constraint_map:
    ...

Copy link
Member Author

Choose a reason for hiding this comment

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

je suis d'accord, c'est mieux, mon but ici n'était pas de faire un gros refactoring. je veux bien m'en occuper quand on fera une refonte du front

antarest/study/web/study_data_blueprint.py Show resolved Hide resolved
antarest/study/web/study_data_blueprint.py Show resolved Hide resolved
@laurent-laporte-pro laurent-laporte-pro force-pushed the bugfix/fix-case-sensitivity-for-bc-constraint-term-id branch from 6f51372 to c7184d8 Compare February 2, 2024 22:27
@laurent-laporte-pro laurent-laporte-pro force-pushed the bugfix/fix-case-sensitivity-for-bc-constraint-term-id branch from c7184d8 to b599f09 Compare February 3, 2024 12:35
@laurent-laporte-pro laurent-laporte-pro merged commit 938e603 into dev Feb 4, 2024
6 checks passed
@laurent-laporte-pro laurent-laporte-pro deleted the bugfix/fix-case-sensitivity-for-bc-constraint-term-id branch February 4, 2024 20:14
@makdeuneuv makdeuneuv added this to the v2.16.4 milestone Feb 12, 2024
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.

Adding terms in binding constraints doesn't work
3 participants