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

Ensure we help people send the right country codes and language codes #233

Open
2 tasks
teolemon opened this issue Sep 16, 2021 · 4 comments
Open
2 tasks

Comments

@teolemon
Copy link
Member

  • Ensure we help people send the right country codes and language codes
    • Example: UK, GB, UE
@monsieurtanuki
Copy link
Contributor

I think it's already fixed for languages: String lc being deprecated and OpenFoodFactsLanguage language being used instead.

A solution for countries would be to

  • create a class OpenFoodFactsCountry
  • populate it with an enum, extended with 2-letter ISO code
  • deprecate the use of cc in AbstractQueryConfiguration, overridden by a new OpenFoodFactsCountry? country parameter

@teolemon Is that correct? May I start coding that?

@teolemon
Copy link
Member Author

We discussed that again last evening with @alexgarel and @jasmeet0817 and the consensus seemed to go for a server side fix.
Here's the server side place where it happens: https://github.com/openfoodfacts/openfoodfacts-server/blob/12d65665d997902b6a4850f5c55ba313ed320150/cgi/product_jqm_multilingual.pl#L231

Trying to gather a few more opinions before answering

@monsieurtanuki
Copy link
Contributor

@teolemon Understood.
The legitimate question of fixing the potentially flawed data provided by the user is not in contradiction with my suggestion, though.
Creating an enum would bring clarity to the code. For the moment all we say is that there's a parameter called cc, that it is a String and that it is optional. A parameter named OpenFoodFactsCountry? country is easier to understand.

monsieurtanuki added a commit to monsieurtanuki/openfoodfacts-dart that referenced this issue Nov 15, 2021
…n "cc"

New file:
* `CountryHelper.dart`: country enums and their ISO-2-codes

Impacted files:
* `AbstractQueryConfiguration.dart`: deprecated `String? cc` in favor of `OpenFoodFactsCountry? country`
* `api_getTaxonomy_test.dart`: now using `OpenFoodAPIConfiguration.globalCountry`
* `api_getTaxonomyAdditives_test.dart`: now using `OpenFoodAPIConfiguration.globalCountry`
* `api_getTaxonomyAllergens_test.dart`: now using `OpenFoodAPIConfiguration.globalCountry`
* `api_getTaxonomyCategories_test.dart`: now using `OpenFoodAPIConfiguration.globalCountry`
* `api_getTaxonomyCountries_test.dart`: now using `OpenFoodAPIConfiguration.globalCountry`
* `api_getTaxonomyIngredients_test.dart`: now using `OpenFoodAPIConfiguration.globalCountry`
* `api_getTaxonomyLabels_test.dart`: now using `OpenFoodAPIConfiguration.globalCountry`
* `api_getTaxonomyLanguages_test.dart`: now using `OpenFoodAPIConfiguration.globalCountry`
* `OpenFoodAPIConfiguration.dart`: deprecated `String? globalCC` in favor of `OpenFoodFactsCountry? globalCountry`
* `openfoodfacts.dart`: minor refactoring
* `ProductListQueryConfiguration.dart`: added parameter `OpenFoodFactsCountry? country`
* `ProductQueryConfigurations.dart`: added parameter `OpenFoodFactsCountry? country`
* `ProductSearchQueryConfiguration.dart`: added parameter `OpenFoodFactsCountry? country`
* `TaxonomyAdditive.dart`: added parameter `OpenFoodFactsCountry? country`
* `TaxonomyAllergen.dart`: added parameter `OpenFoodFactsCountry? country`
* `TaxonomyCategory.dart`: added parameter `OpenFoodFactsCountry? country`
* `TaxonomyCountry.dart`: added parameter `OpenFoodFactsCountry? country`
* `TaxonomyIngredient.dart`: added parameter `OpenFoodFactsCountry? country`
* `TaxonomyLabel.dart`: added parameter `OpenFoodFactsCountry? country`
* `TaxonomyLanguage.dart`: added parameter `OpenFoodFactsCountry? country`
* `TaxonomyQueryConfiguration.dart`: deprecated `String? cc` in favor of `OpenFoodFactsCountry? country`
monsieurtanuki added a commit to monsieurtanuki/openfoodfacts-dart that referenced this issue Nov 15, 2021
Impacted files:
* `api_getProduct_test.dart`: not using deprecated parameter `lc` anymore
* `ProductListQueryConfiguration.dart`: deprecated parameters `lc` and `cc`
* `ProductQueryConfigurations.dart`: deprecated parameters `lc` and `cc`
* `ProductSearchQueryConfiguration.dart`: deprecated parameters `lc` and `cc`
* `TaxonomyAdditive.dart`: deprecated parameter cc`
* `TaxonomyAllergen.dart`: deprecated parameter cc`
* `TaxonomyCategory.dart`: deprecated parameter cc`
* `TaxonomyCountry.dart`: deprecated parameter cc`
* `TaxonomyIngredient.dart`: deprecated parameter cc`
* `TaxonomyLabel.dart`: deprecated parameter cc`
* `TaxonomyLanguage.dart`: deprecated parameter cc`
monsieurtanuki added a commit that referenced this issue Nov 19, 2021
New file:
* `CountryHelper.dart`: country enums and their ISO-2-codes

Impacted files:
* `AbstractQueryConfiguration.dart`: deprecated `String? cc` in favor of `OpenFoodFactsCountry? country`
* `api_getTaxonomy_test.dart`: now using `OpenFoodAPIConfiguration.globalCountry`
* `api_getTaxonomyAdditives_test.dart`: now using `OpenFoodAPIConfiguration.globalCountry`
* `api_getTaxonomyAllergens_test.dart`: now using `OpenFoodAPIConfiguration.globalCountry`
* `api_getTaxonomyCategories_test.dart`: now using `OpenFoodAPIConfiguration.globalCountry`
* `api_getTaxonomyCountries_test.dart`: now using `OpenFoodAPIConfiguration.globalCountry`
* `api_getTaxonomyIngredients_test.dart`: now using `OpenFoodAPIConfiguration.globalCountry`
* `api_getTaxonomyLabels_test.dart`: now using `OpenFoodAPIConfiguration.globalCountry`
* `api_getTaxonomyLanguages_test.dart`: now using `OpenFoodAPIConfiguration.globalCountry`
* `OpenFoodAPIConfiguration.dart`: deprecated `String? globalCC` in favor of `OpenFoodFactsCountry? globalCountry`
* `openfoodfacts.dart`: minor refactoring
* `ProductListQueryConfiguration.dart`: added parameter `OpenFoodFactsCountry? country`
* `ProductQueryConfigurations.dart`: added parameter `OpenFoodFactsCountry? country`
* `ProductSearchQueryConfiguration.dart`: added parameter `OpenFoodFactsCountry? country`
* `TaxonomyAdditive.dart`: added parameter `OpenFoodFactsCountry? country`
* `TaxonomyAllergen.dart`: added parameter `OpenFoodFactsCountry? country`
* `TaxonomyCategory.dart`: added parameter `OpenFoodFactsCountry? country`
* `TaxonomyCountry.dart`: added parameter `OpenFoodFactsCountry? country`
* `TaxonomyIngredient.dart`: added parameter `OpenFoodFactsCountry? country`
* `TaxonomyLabel.dart`: added parameter `OpenFoodFactsCountry? country`
* `TaxonomyLanguage.dart`: added parameter `OpenFoodFactsCountry? country`
* `TaxonomyQueryConfiguration.dart`: deprecated `String? cc` in favor of `OpenFoodFactsCountry? country`

* feat: #233 - explicitly deprecated parameters `lc` and `cc`

Impacted files:
* `api_getProduct_test.dart`: not using deprecated parameter `lc` anymore
* `ProductListQueryConfiguration.dart`: deprecated parameters `lc` and `cc`
* `ProductQueryConfigurations.dart`: deprecated parameters `lc` and `cc`
* `ProductSearchQueryConfiguration.dart`: deprecated parameters `lc` and `cc`
* `TaxonomyAdditive.dart`: deprecated parameter cc`
* `TaxonomyAllergen.dart`: deprecated parameter cc`
* `TaxonomyCategory.dart`: deprecated parameter cc`
* `TaxonomyCountry.dart`: deprecated parameter cc`
* `TaxonomyIngredient.dart`: deprecated parameter cc`
* `TaxonomyLabel.dart`: deprecated parameter cc`
* `TaxonomyLanguage.dart`: deprecated parameter cc`
@monsieurtanuki
Copy link
Contributor

@teolemon #292 partially answers this issue, with explicit country codes.
If the issue is more about an implicit country-to-default-language map, that's another story. Even more if this map is dealt with on the server side - what did you guys decide eventually?
Please feel free to close this issue or to add specs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants