openfoodfacts/smooth-app

Allow to filter search results based on one country and one or several stores

teolemon opened this issue · 8 comments

What

Part of

@teolemon There are obvious problems with accents in https://static.openfoodfacts.org/data/taxonomies/stores.json

Where will the filter happen: in the query itself (additional API parameters) or when we get the results?

Let's perhaps drop stores (it doesn't have country for stores anyway) and only keep country filtering (we could use the system's country list, or Open Food Fact's : https://static.openfoodfacts.org/data/taxonomies/countries.json

Beyond the "just the country, not the stores" simplification, I still have the same question:
Where will the filter happen: in the query itself (additional API parameters) or when we get the results?

I think we should do the reverse: by default, search only products for the current country, and offer to widen the search to the world, as we do on the web site.

The filter should happen in the query.

How should we add the country parameter in the query?
For instance, in KeywordsProductQuery, I assume it's in ProductSearchQueryConfiguration, but how?

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),
  ),
);

We now have a country selector.

  • Will Probably be solved by #1371