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: 4068 - autocomplete for brands #4871

Merged
merged 9 commits into from
Dec 21, 2023

Conversation

monsieurtanuki
Copy link
Contributor

What

  • Added autocomplete for brands.
  • Refactored the code in the process.

Screenshot

Screenshot_1701684321

Fixes bug(s)

Files

New files:

  • agnostic_suggestion_manager.dart: Suggestion manager for "old" and elastic search taxonomies.
  • brand_suggestion_manager.dart: Manager that returns the elastic suggestions for the latest brand input.
  • smooth_autocomplete_text_field.dart: Autocomplete text field. Code largely moved from simple_input_text_field.dart.
  • unfocus_when_tap_outside.dart: Allows to unfocus TextField (and dismiss the keyboard). Code moved from simple_input_text_field.dart.

Impacted files:

  • add_basic_details_page.dart: added elastic autocomplete for brands
  • edit_new_packagings.dart: minor refactoring
  • paged_to_be_completed_product_query.dart: minor refactoring
  • paged_user_product_query.dart: minor refactoring
  • pubspec.lock: wtf
  • pubspec.yaml: ugraded to openfoodfacts 3.2.1
  • simple_input_page.dart: minor refactoring
  • simple_input_text_field.dart: moved most of the code to new class SmoothAutocompleteTextField in order to deal also with elastic search autocompletion.

New files:
* `agnostic_suggestion_manager.dart`: Suggestion manager for "old" and elastic search taxonomies.
* `brand_suggestion_manager.dart`: Manager that returns the elastic suggestions for the latest brand input.
* `smooth_autocomplete_text_field.dart`: Autocomplete text field. Code largely moved from `simple_input_text_field.dart`.
* `unfocus_when_tap_outside.dart`: Allows to unfocus TextField (and dismiss the keyboard). Code moved from `simple_input_text_field.dart`.

Impacted files:
* `add_basic_details_page.dart`: added elastic autocomplete for brands
* `edit_new_packagings.dart`: minor refactoring
* `paged_to_be_completed_product_query.dart`: minor refactoring
* `paged_user_product_query.dart`: minor refactoring
* `pubspec.lock`: wtf
* `pubspec.yaml`: ugraded to openfoodfacts 3.2.1
* `simple_input_page.dart`: minor refactoring
* `simple_input_text_field.dart`: moved most of the code to new class `SmoothAutocompleteTextField` in order to deal also with elastic search autocompletion.
// TODO(monsieurtanuki): there's probably a more elegant way to do it.
/// Suggestion manager for "old" taxonomies and elastic search taxonomies.
class AgnosticSuggestionManager {
AgnosticSuggestionManager.tagType(this.tagTypeSuggestionManager)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wouldn't a factory be a nicer API.
It would allow to hide the complexity of the implementation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@g123k I honestly cannot see how a factory would help, but I would gladly see what you would write instead.
Btw I wouldn't call the code of this file "complex" (one class, 28 lines of code, 2 fields, 1 method).

@teolemon
Copy link
Member

teolemon commented Dec 4, 2023

10:55
Raphaël Bournhonesque
I deployed Open Food Facts search in prod 🙂
https://search.openfoodfacts.org/

@monsieurtanuki
Copy link
Contributor Author

10:55 Raphaël Bournhonesque I deployed Open Food Facts search in prod 🙂 https://search.openfoodfacts.org/

@teolemon Doesn't seem to work for brands autocomplete for the moment.

@monsieurtanuki
Copy link
Contributor Author

10:55 Raphaël Bournhonesque I deployed Open Food Facts search in prod 🙂 https://search.openfoodfacts.org/

@teolemon Doesn't seem to work for brands autocomplete for the moment.

Still getting the Internal Server Error.

@teolemon
Copy link
Member

teolemon commented Dec 8, 2023

@raphael0202

@raphael0202
Copy link

@monsieurtanuki sorry I missed your comment. I didn't import the taxonomies, only the product data. I will do it this week!

@monsieurtanuki
Copy link
Contributor Author

Thank you @raphael0202, ping me when you're done!

@raphael0202
Copy link

@monsieurtanuki It's done!

@monsieurtanuki
Copy link
Contributor Author

Thank you @raphael0202! I've just updated the PR in order to target PROD brands instead of DEV brands.
@g123k @teolemon I'm done here. Feel free to review.

@codecov-commenter
Copy link

codecov-commenter commented Dec 15, 2023

Codecov Report

Attention: 198 lines in your changes are missing coverage. Please review.

Comparison is base (e5757e7) 9.67% compared to head (f030780) 9.64%.

Files Patch % Lines
...ib/pages/input/smooth_autocomplete_text_field.dart 0.00% 92 Missing ⚠️
..._app/lib/pages/product/add_basic_details_page.dart 0.00% 57 Missing ⚠️
..._app/lib/pages/input/brand_suggestion_manager.dart 0.00% 18 Missing ⚠️
...app/lib/pages/product/simple_input_text_field.dart 0.00% 14 Missing ⚠️
...p/lib/pages/input/agnostic_suggestion_manager.dart 0.00% 9 Missing ⚠️
..._app/lib/pages/input/unfocus_when_tap_outside.dart 0.00% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           develop   #4871      +/-   ##
==========================================
- Coverage     9.67%   9.64%   -0.03%     
==========================================
  Files          319     323       +4     
  Lines        16147   16197      +50     
==========================================
  Hits          1563    1563              
- Misses       14584   14634      +50     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@g123k g123k left a comment

Choose a reason for hiding this comment

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

OK there's just a suggestion, so let's go as-is

@monsieurtanuki monsieurtanuki merged commit 2554848 into openfoodfacts:develop Dec 21, 2023
6 checks passed
@monsieurtanuki
Copy link
Contributor Author

Thank you @g123k for the review!

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

Successfully merging this pull request may close these issues.

Add brand autocomplete from openfoodfacts-search
5 participants