openfoodfacts / smooth-app

🤳🥫 The new Open Food Facts mobile application for Android and iOS, crafted with Flutter and Dart
https://world.openfoodfacts.org/open-food-facts-mobile-app?utm_source=off&utf_medium=web&utm_campaign=github-repo
Apache License 2.0
865 stars 285 forks source link

Allow to add prices of products without barcode #5553

Open raphael0202 opened 3 months ago

raphael0202 commented 3 months ago

Problem

Currently, we cannot add the price of a product without barcode (products such as fruit/vegetables that are sold per kg or per unit). It would be great to add it!

For the record, it's available on the web version of Open Prices.

monsieurtanuki commented 3 months ago

@raphael0202 We're blocked because in off-dart and Smoothie we're only able to autocomplete labels (e.g. 'Tomate'), and we don't retrieve the matching tags (e.g. 'en:tomatoes') and we don't have a way to retrieve the tags from the labels. In Prices you want the tags...

monsieurtanuki commented 3 months ago

@raphael0202 @teolemon Besides, that means we cannot do that offline one way or the other. Perhaps a decent minimal map of {tag: label} with standard fruits and stored locally would help.

raphael0202 commented 2 months ago

I think it should be added to the autocomplete API on Product Opener. But we can definitely add support for language-specific tags on Open Prices side.

monsieurtanuki commented 1 month ago

@raphael0202 I don't know which solution is more pragmatic. Meanwhile, we're blocked here at Smoothie.

raphael0202 commented 4 weeks ago

@raphael0202 I don't know which solution is more pragmatic. Meanwhile, we're blocked here at Smoothie.

It's definitely the Open Prices addition. It's on my todo list ;)

monsieurtanuki commented 4 weeks ago

It's definitely the Open Prices addition. It's on my todo list ;)

@raphael0202 Cool! Keep in mind that here at Smoothie we use background tasks and "normal" users have no control over them. If for some reason what I give you is not good enough, what would be your reaction? Ignore the price (without feedback to the user)? Return an error (and I will retry forever)? Btw there's also the question of the category value you'll return: if you return a tag (e.g. 'en:tomatoes') I'll need a translated label. It means I'll have to call api/v2/taxonomy with all the tags you'll return from Prices. Not very convenient, that second call. To be investigated.

raphael0202 commented 3 weeks ago

If for some reason what I give you is not good enough, what would be your reaction? Ignore the price (without feedback to the user)? Return an error (and I will retry forever)?

I think the retry strategy should really depend on the HTTP error code. In case of a 5XX error, it's definitely worth trying again later. If it's a 4XX, I think Smoothie should drop the task.

And users can provide any category (even ones that don't exist in the taxonomy)?

Btw there's also the question of the category value you'll return: if you return a tag (e.g. 'en:tomatoes') I'll need a translated label. It means I'll have to call api/v2/taxonomy with all the tags you'll return from Prices. Not very convenient, that second call. To be investigated.

That's an issue indeed, we should think about adding translations to the output response. ping @raphodn FYI

monsieurtanuki commented 3 weeks ago

I think the retry strategy should really depend on the HTTP error code. In case of a 5XX error, it's definitely worth trying again later. If it's a 4XX, I think Smoothie should drop the task.

Sounds fair, except that we don't provide any feedback in Smoothie about background tasks. The user thinks the price is added, and it'll never be. But it's more a problem on the Smoothie side than on the Prices side.

raphael0202 commented 3 weeks ago

As agreed, I added support for language-specific categories in https://github.com/openfoodfacts/open-prices/pull/548.

We can now submit fr: Abricots as a category, and it translates it automatically to en:apricots. Note that we don't support (yet) extended synonyms, so we should provide the canonical taxonomy ID (or it's direct synonyms) as value, but it shouldn't be an issue, as you will probably use the taxonomy translations for auto-complete.

If the value is not recognized, we save it as-it.

It's available in staging :)

monsieurtanuki commented 3 weeks ago

@raphael0202 Cool! Just checking: should we add a space after the semicolon (fr: Abricots) or is it a typo (fr:Abricots instead)?

monsieurtanuki commented 3 weeks ago

@raphael0202 Tested this morning and it looks OK for category, where fr:Pomme de terre de Noirmoutier was correctly interpreted as en:potatoes-from-noirmoutier. Now that you're here, we have the same kind of issue with origins_tags: could you interpret/translate them as well?

raphael0202 commented 3 weeks ago

You can add a space or not, both are supported! Oh ok, I will add it next week!

monsieurtanuki commented 3 weeks ago

Oh ok, I will add it next week!

@raphael0202 Cool! Please ping me when you're done.

raphael0202 commented 2 weeks ago

@monsieurtanuki It's deployed in production :)

monsieurtanuki commented 2 weeks ago

@raphael0202 Both categories and origins in production, then. Thanks!

raphodn commented 1 week ago

fyi I created an issue - https://github.com/openfoodfacts/open-prices/issues/575 - linked to this discussion : adding a new Price.type field, to clearly seperate price for products with or without barcode

monsieurtanuki commented 5 days ago

@raphodn Of course you know the impact of making this field mandatory: Smoothie wouldn't be able to create any price, unless all users upgrade their app after a new app version.

That said, this field could be optional when creating a price, and computed (and checked) by Prices server anyway:

raphodn commented 5 days ago

Update : the field (optional) is available in staging. And in production tomorrow. It'll be filled & returned for every price.