Skip to content
This repository has been archived by the owner on Jul 6, 2022. It is now read-only.

Allow filtering by store #369

Open
Tracked by #409
teolemon opened this issue Feb 2, 2022 · 10 comments
Open
Tracked by #409

Allow filtering by store #369

teolemon opened this issue Feb 2, 2022 · 10 comments
Labels

Comments

@teolemon
Copy link
Member

teolemon commented Feb 2, 2022

What

  • Allow filtering by store to allow focused contributions

Mockup

image

Part of

@Jagrutiti
Copy link
Member

Hi @teolemon I would like to work on this filter issue. Could you give some more description?

@Jagrutiti
Copy link
Member

Hi. I have one question in general about Hunger games, not particularly about this issue.

If I have understood Hunger games correctly almost all the functionality is done by API. Is there anywhere we use the database, I understand that Open Food Facts uses MongoDB for the backend.

I wanted to understand when we use API and when do we use the database? Or do we use only API?

@Jagrutiti
Copy link
Member

Also, is there documentation to understand the APIs better?

@Jagrutiti
Copy link
Member

Hi @teolemon

Since I was working with robotoff APIs earlier, I have an idea of how to proceed.

but it seems stores is not yet supported by the API

What did you mean by not supported by API?

I cannot continue with the task?

@alexfauquette
Copy link
Member

To answer your first question, hungergame is a vueJS app so it runs fully on client-side. Then the only way to access data from servers is the API.

About your second question, in this game robotoff is the API we call the get a list of questions. For now, this API does not allows to get only question about products in a given store

The parameters you can pass in the API request are here:
https://github.com/openfoodfacts/robotoff/blob/5b9252d298bda2b56fdd530aee50e13112f13912/robotoff/app/api.py#L915-L928

And stores_tags is not used, so the two following lines are the same for the API

  • robotoff.openfoodfacts.org/api/v1/questions/random?count=10&lang=en&insight_types=label&stores_tags=auchan
  • robotoff.openfoodfacts.org/api/v1/questions/random?count=10&lang=en&insight_types=label

@Jagrutiti
Copy link
Member

And stores_tags is not used, so the two following lines are the same for the API

This means, that we want to sort by store by can't use the existing API directly?

So I need to write a function in JavaScript to sort by store?

robotoff.openfoodfacts.org/api/v1/questions/random?count=10&lang=en&insight_types=label

In the API response, I didn't find the store names?

@Jagrutiti
Copy link
Member

Hey @alexfauquette

Do I get the store list from this API here? https://world.openfoodfacts.org/stores.json

@Jagrutiti
Copy link
Member

Hi @alexfauquette

I was going through the code, the data in the this.questionBuffer is so:

{
        "barcode": "8717825668590",
        "type": "add-binary",
        "value": "Non-EU Agriculture",
        "question": "Does the product have this label?",
        "insight_id": "9abf8aae-11d0-461c-be0a-1a035682b68c",
        "insight_type": "label",
        "value_tag": "en:non-eu-agriculture",
        "source_image_url": "https://static.openfoodfacts.org/images/products/871/782/566/8590/1.400.jpg"
    }

I can filter data in this.questionBuffer, or maybe call another API that returns stores, and match with barcode (depends on data returned by the other API).

I have understood the problem. The thing is I am not able to figure out where to get the store_tags to start with filtering?

@alexfauquette
Copy link
Member

As said previously, the API is not ready and without it, you can not solve this issue. Either you like python and add filtering by the store on robotoff API, or you just wait for it to be added by the team.

I do not know any other solutions. Stores are accessible in openfoodfact API, questions are from robotoff API. And trying to make a join between two APIs is clearly a bad idea

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
Status: No status
Development

No branches or pull requests

3 participants