openfoodfacts / open-prices

An open database of prices 🧾💸💰🏷️🤑🍽️
https://prices.openfoodfacts.org
GNU Affero General Public License v3.0
42 stars 12 forks source link

Detect (and ignore) duplicate prices #422

Open raphodn opened 2 months ago

raphodn commented 2 months ago

Story

I sometimes see "identical" prices. Reasons could be a mistake (scanning/adding the product twice), or adding a price from a receipt and then from another source like GDPR, API error...)

Identical price = same product + same location + same date (not necessarily the same proof ; if 2 different proofs, which one to keep ?)

And should we allow 2 identical products on the same proof ? Only if the price is different (in which case would that happen ?) ?

Linked issues & comments

raphodn commented 1 month ago

What happens when a duplicate price is sent to the API:

Should the user be informed that the price was ignored by the server ?

raphodn commented 1 month ago

What about duplicate proofs ? Much harder to detect, or we would need to store a hash, and check if a Proof with the same user already exists

Related issue : https://github.com/openfoodfacts/open-prices-frontend/issues/534

edit : created a dedicated issue : https://github.com/openfoodfacts/open-prices/issues/514

monsieurtanuki commented 1 month ago

For the moment in off-dart's createPrice we expect a status code of 201 ("Created").

We may return the "old" price and let the developer deal with it (checking field by field). If needed, the developer may then decide to delete the "old" price and add the new one.

Possibly, you may also return 409 as a "Conflict" status code.

Anyway, whatever you decide should probably take into account our low reactivity in Smoothie: coding can be fast, but the app roll out can take months. Perhaps in 2 steps: the "return the old" now and the "409" in one year? Or both possibilities in a different api version number.