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

feat: #2339 - added language and country to query product list keys #2465

Merged
merged 1 commit into from
Jul 2, 2022

Conversation

monsieurtanuki
Copy link
Contributor

What

  • added language and country to query product list keys
  • that means that if I run a query for "pizza", not only the results will be different depending on the language and country (that was already the case), but the results will be cached accordingly - if I change language or country, I will see the cached results for those new language/country, not the results of the same query but with different language/country
  • we needed that improvement in order to display correctly the "world" results; that was the first step
  • also moved all the "query" classes to a specific folder
  • fun fact: there are more "pizza"s in France than in Italy

Impacted files:

  • abstract_onboarding_data.dart: minor refactoring
  • barcode_product_query.dart: moved; minor refactoring
  • category_product_query.dart: moved; added language and country to product list key
  • continuous_scan_model.dart: minor refactoring
  • country_selector.dart: minor refactoring
  • database_product_list_supplier.dart: minor refactoring
  • keywords_product_query.dart: moved; added language and country to product list key
  • main.dart: minor refactoring
  • new_product_page.dart: minor refactoring
  • nutrition_page_loaded.dart: minor refactoring
  • ocr_helper.dart: minor refactoring
  • onboarding_data_product.dart: minor refactoring
  • ordered_nutrients_cache.dart: minor refactoring
  • paged_product_query.dart: moved; added language and country to product list key; refactored around getProducts
  • paged_search_product_query.dart: moved; refactored
  • paged_to_be_completed_product_query.dart: moved; added language and country to product list key; refactored
  • paged_user_product_query.dart: moved; added language to product list key; refactored
  • picture_capture_helper.dart: minor refactoring
  • product_dialog_helper.dart: minor refactoring
  • product_list.dart: added optional language and country to constructor parameters
  • product_list_import_export.dart: minor refactoring
  • product_list_page.dart: minor refactoring
  • product_list_supplier.dart: minor refactoring
  • product_query.dart: moved; not an interface anymore
  • product_query_model.dart: minor refactoring
  • product_query_page_helper.dart: minor refactoring
  • product_refresher.dart: minor refactoring
  • query_product_list_supplier.dart: minor refactoring
  • robotoff_insight_helper.dart: minor refactoring
  • robotoff_questions_query.dart: moved; minor refactoring
  • search_page.dart: minor refactoring
  • simple_input_page_helpers.dart: minor refactoring
  • summary_card.dart: minor refactoring
  • user_preferences_account.dart: minor refactoring
  • user_preferences_dev_mode.dart: minor refactoring

Part of

…t list keys

What:
* added language and country to query product list keys
* that means that if I run a query for "pizza", not only the results will be different depending on the language and country (that was already the case), but the results will be cached accordingly - if I change language or country, I will see the cached results for those new language/country, not the results of the same query but with different language/country
* we needed that improvement in order to display correctly the "world" results; that was the first step
* also moved all the "query" classes to a specific folder
* fun fact: there are more "pizza"s in France than in Italy

Impacted files:
* `abstract_onboarding_data.dart`: minor refactoring
* `barcode_product_query.dart`: moved; minor refactoring
* `category_product_query.dart`: moved; added language and country to product list key
* `continuous_scan_model.dart`: minor refactoring
* `country_selector.dart`: minor refactoring
* `database_product_list_supplier.dart`: minor refactoring
* `keywords_product_query.dart`: moved; added language and country to product list key
* `main.dart`: minor refactoring
* `new_product_page.dart`: minor refactoring
* `nutrition_page_loaded.dart`: minor refactoring
* `ocr_helper.dart`: minor refactoring
* `onboarding_data_product.dart`: minor refactoring
* `ordered_nutrients_cache.dart`: minor refactoring
* `paged_product_query.dart`: moved; added language and country to product list key; refactored around `getProducts`
* `paged_search_product_query.dart`: moved; refactored
* `paged_to_be_completed_product_query.dart`: moved; added language and country to product list key; refactored
* `paged_user_product_query.dart`: moved; added language to product list key; refactored
* `picture_capture_helper.dart`: minor refactoring
* `product_dialog_helper.dart`: minor refactoring
* `product_list.dart`: added optional language and country to constructor parameters
* `product_list_import_export.dart`: minor refactoring
* `product_list_page.dart`: minor refactoring
* `product_list_supplier.dart`: minor refactoring
* `product_query.dart`: moved; not an interface anymore
* `product_query_model.dart`: minor refactoring
* `product_query_page_helper.dart`: minor refactoring
* `product_refresher.dart`: minor refactoring
* `query_product_list_supplier.dart`: minor refactoring
* `robotoff_insight_helper.dart`: minor refactoring
* `robotoff_questions_query.dart`: moved; minor refactoring
* `search_page.dart`: minor refactoring
* `simple_input_page_helpers.dart`: minor refactoring
* `summary_card.dart`: minor refactoring
* `user_preferences_account.dart`: minor refactoring
* `user_preferences_dev_mode.dart`: minor refactoring
@codecov-commenter
Copy link

Codecov Report

Merging #2465 (029b3e0) into develop (2ea0da3) will decrease coverage by 1.37%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           develop   #2465      +/-   ##
==========================================
- Coverage     8.86%   7.49%   -1.38%     
==========================================
  Files          161     205      +44     
  Lines         6623    9825    +3202     
==========================================
+ Hits           587     736     +149     
- Misses        6036    9089    +3053     
Impacted Files Coverage Δ
...kages/smooth_app/lib/widgets/attribute_button.dart 0.00% <0.00%> (-92.00%) ⬇️
...s/smooth_app/lib/data_models/user_preferences.dart 8.73% <0.00%> (-23.57%) ⬇️
packages/smooth_app/lib/themes/smooth_theme.dart 60.00% <0.00%> (-22.98%) ⬇️
...p/lib/generic_lib/dialogs/smooth_alert_dialog.dart 15.29% <0.00%> (-18.92%) ⬇️
...mooth_app/lib/data_models/product_preferences.dart 24.65% <0.00%> (-6.78%) ⬇️
packages/smooth_app/lib/main.dart 14.40% <0.00%> (-3.49%) ⬇️
.../smooth_app/lib/pages/onboarding/welcome_page.dart 0.00% <0.00%> (-3.13%) ⬇️
.../smooth_app/lib/pages/onboarding/scan_example.dart 0.00% <0.00%> (-2.28%) ⬇️
...p/lib/pages/onboarding/consent_analytics_page.dart 0.00% <0.00%> (-1.57%) ⬇️
...smooth_app/lib/pages/product/new_product_page.dart 0.00% <0.00%> (-0.88%) ⬇️
... and 214 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f28ad14...029b3e0. Read the comment docs.

Copy link
Member

@M123-dev M123-dev left a comment

Choose a reason for hiding this comment

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

Looks great, thanks @monsiertarnuki

CC: @AshAman999 probably interesting for you

@monsieurtanuki monsieurtanuki merged commit 9e253a7 into openfoodfacts:develop Jul 2, 2022
@monsieurtanuki
Copy link
Contributor Author

Thank you @M123-dev for your review!
As you're mentioning @AshAman999 it makes me think about the offline database, and I've just noticed that the primary key of a Product is the barcode but without the language. Therefore, we can't have a product in different languages: just one Product for one barcode, the latest downloaded versions wins. Should we have a version for each language? I don't know.

@M123-dev
Copy link
Member

M123-dev commented Jul 2, 2022

@AshAman999 is the right one to ask but as the ultimate goal is to be able to allow multiple different datasets for countries that's probably a good idea + a a own field for language to be able to explicitly get data for a single data set.

"German"
"500.000 Products"
"300mb:

Similar to Google Maps but don't take my word for granted let's wait for @AshAman999 s answer

@AshAman999
Copy link
Member

Though I am not an expert here dealing with db's, but i am thinking of making multiple tables according to the desired country and language.
So the current table name is String TABLE_PRODUCT = 'product';
What i am thinking here is to do something like this for a table name String TABLE_PRODUCT = 'product_$language_$country';
In this process i could seperate the products for different coutries and language according to the need here.

Thoughts @monsieurtanuki @M123-dev ,
Would be great to hear yours answer on this as well

@monsieurtanuki
Copy link
Contributor Author

monsieurtanuki commented Jul 4, 2022 via email

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

Successfully merging this pull request may close these issues.

5 participants