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

Exclude items from autosuggestions #889

Open
monsieurtanuki opened this issue Mar 11, 2024 · 4 comments
Open

Exclude items from autosuggestions #889

monsieurtanuki opened this issue Mar 11, 2024 · 4 comments
Assignees

Comments

@monsieurtanuki
Copy link
Contributor

Why - Problem description

cf. openfoodfacts/smooth-app#5096 by @g123k:

In many parts of the edition, we have an auto-completion feature.
However, this is a nonsense to list an item… which is already selected.

What - Proposed solution

The first thing to do would be to add a parameter to the autosuggestion methods: a list of items to exclude.
Then, if the developer asks for 10 items and we exclude 2 items, we should ask the server for 10+2 = 12 items and return the first 10 items that are not in the 2-item list.

Alternatives you've considered

Of course if the server could accept a list of items to exclude it would be better.

@AffanShaikhsurab
Copy link

AffanShaikhsurab commented Jan 23, 2025

i would like to work on it this issue , can you please assign ?

@AffanShaikhsurab
Copy link

i tried to add this approch in the open_food_search_api_client.dart file :

  1. We will add a new parameter called excludedItems to the autocomplete function. This allows developers to pass a list of items they want to exclude from the suggestions.

  2. Inside the function, we first check if the excludedItems list is empty or not provided. If it is empty, we simply return the original list of suggestions as it is.

  3. If the list is not empty, we remove any items in the suggestions that are also in the excludedItems list.

  4. Finally, we return the filtered list of suggestions where the excluded items are no longer present.

is this a valid apporch or it should be in a different file ? or any other imporved method ?

@monsieurtanuki
Copy link
Contributor Author

@AffanShaikhsurab That's good but you're missing a detail: you have to ask for more items, as explained in the OP.

@AffanShaikhsurab
Copy link

can you please see if any changes needed to be done in the pr ?

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