-
-
Notifications
You must be signed in to change notification settings - Fork 287
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
Specify the user country in API queries #133
Comments
It does require a change in openfoodfacts-dart: openfoodfacts/openfoodfacts-dart#76 |
The openfoodfacts-dart change has been merged: openfoodfacts/openfoodfacts-dart#76 |
@stephanegigandet I cannot see the direct impact of that merge for the moment. await OpenFoodAPIClient.searchProducts(
ProductQuery.SMOOTH_USER,
ProductSearchQueryConfiguration(
fields: ProductQuery.fields,
parametersList: <Parameter>[
const PageSize(size: 500),
TagFilter(
tagType: 'categories',
contains: true,
tagName: keywords,
)
],
language: LanguageHelper.fromJson(languageCode),
),
); How should we alter the code? adding something like that to the TagFilter(
tagType: 'cc',
contains: true,
tagName: 'fr',
) And it is available now or should we use a fresher version than |
Ah right, I hadn't noticed there was a specific ProductSearchConfiguration, I will update it. Then it should be:
|
I'll push it in 0.3.15 and publish it: openfoodfacts/openfoodfacts-dart#81 |
@stephanegigandet OK then! Tell me when |
@monsieurtanuki : here is the pull request that adds the cc parameter to ProductSearchQueryConfiguration: openfoodfacts/openfoodfacts-dart#82 |
0.3.15 is deployed: https://pub.dev/packages/openfoodfacts |
@stephanegigandet Cool! For language: LanguageHelper.fromJson(languageCode), with lc: locale.languageCode,
cc: locale.countryCode, But for Pnns search |
Additional remarks:
|
Impacted files: * `choose_page.dart`: added the country code parameter when calling `KeywordsProductQuery` * `keywords_product_query.dart`: replaced `language` parameter by `lc` and `cc`; refactored * `pubspec.yaml`: upgraded `openfoodfacts` to brand new version `^0.3.15`
feature/#133 - added country code parameter for keyword search
well you get 500 results in both cases. try with a smaller country: cc=re (Reunion) and you will get 2 results. but with cc=fr, you get extra data in the attribute_groups as you get the Eco-Score attribute (but the search results are different, so it can also change the size) |
We can add it, but eventually we will need to remove the queryPnnsGroup functions from the Dart package, they should not be needed. The PNNS queries are just search queries with a filter on a parameter, just like the keywords search queries etc. |
@stephanegigandet My remarks:
|
@monsieurtanuki : I'll fix the cc=RE server side: openfoodfacts/openfoodfacts-server#4833 |
@monsieurtanuki : I was more thinking about the implementation of those PNNS queries in openfoodfacts-dart: we can get the exact same functionality without special code for it. I just filed an issue regarding that: openfoodfacts/openfoodfacts-dart#92 The PNNS category browsing feature is interesting, I was not suggesting to remove it. |
cf. #19 I guess |
Hey, by the way this issue can now be closed, on the flutter side at least. |
Server side fix for the uppercase country code: openfoodfacts/openfoodfacts-server#4834 |
The returned results may differ by country of request. e.g. we currently disable the Eco-Score attribute unless the country is set to France (either by having the "cc" parameter set to "fr", or the query sent to fr.openfoodfacts.org). This may require changes in the openfoodfacts-dart package, I haven't checked yet.
The text was updated successfully, but these errors were encountered: