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

Geting values from all products with a particular property #37

Closed
CharlesNepote opened this issue Sep 10, 2021 · 1 comment
Closed

Geting values from all products with a particular property #37

CharlesNepote opened this issue Sep 10, 2021 · 1 comment
Labels
✨ enhancement New feature or request

Comments

@CharlesNepote
Copy link
Member

CharlesNepote commented Sep 10, 2021

Description

When I look at the list of all products filtered by a particular property, I would like to get the value for each product. Currently, the API only returns the product code, the number of keys (always 1 when filtering by a property), the editors and the last edit date:

[
  {"product":"0678963100206","keys":1,"last_edit":"2021-06-10T08:48:26.049005","editors":1},
  {"product":"4003171036249","keys":1,"last_edit":"2021-06-10T08:44:00.97486","editors":1},
  {"product":"8857124162105","keys":1,"last_edit":"2021-05-21T08:43:43.330521","editors":1}
]

Usages:

  • quickly observe what kind of values are currently used for a given property
  • quickly identify wrong values
  • quickly observe most or least given values
  • build "suggest values as you type" feature (based on most given values or based on all the values when a property only has a small number of values)

Implementation

Suggestion 1

The call shouldn't change, eg. https://api.folksonomy.openfoodfacts.org/products?k=packaging:character
The resulting JSON should be like that:

[
    {
        "product": "3057640241093",
        "keys": 1,
        "last_edit": "2021-06-06T16:22:35.550845",
        "editors": 1,
        "value": "Darth Vader"
    },
    {
        "product": "3245550465580",
        "keys": 1,
        "last_edit": "2021-05-31T08:22:29.697113",
        "editors": 1,
        "value": "Yoda from Star Wars"
    },
    {
        "product": "9310036071174",
        "keys": 1,
        "last_edit": "2021-05-27T15:47:05.58417",
        "editors": 1,
        "value": "Star Wars' stormtrooper"
    }
]

Suggestion 2

The current call of products filtered by a key also have drawbacks:

  • useless "keys": 1 for each product
  • not so useful "editors": 1 for each product

There could be another route like: https://api.folksonomy.openfoodfacts.org/key/packaging:character
which could return fewer things:

[
    {
        "product": "3057640241093",
        "last_edit": "2021-06-06T16:22:35.550845",
        "value": "Darth Vader"
    },
    {
        "product": "3245550465580",
        "last_edit": "2021-05-31T08:22:29.697113",
        "value": "Yoda from Star Wars"
    },
    {
        "product": "9310036071174",
        "last_edit": "2021-05-27T15:47:05.58417",
        "value": "Star Wars' stormtrooper"
    }
]
@CharlesNepote
Copy link
Member Author

Done with new routes:

  • /products/stats (formerly /products)
  • /products?k=xxx (which now returns all products with k xxx)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant