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

Allow to add prices of products without barcode #5553

Open
raphael0202 opened this issue Aug 20, 2024 · 18 comments
Open

Allow to add prices of products without barcode #5553

raphael0202 opened this issue Aug 20, 2024 · 18 comments

Comments

@raphael0202
Copy link

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
Copy link
Contributor

@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
Copy link
Contributor

@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
Copy link
Author

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
Copy link
Contributor

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

@raphael0202
Copy link
Author

@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
Copy link
Contributor

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
Copy link
Author

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
Copy link
Contributor

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
Copy link
Author

As agreed, I added support for language-specific categories in openfoodfacts/open-prices#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
Copy link
Contributor

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

@monsieurtanuki
Copy link
Contributor

@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
Copy link
Author

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

@monsieurtanuki
Copy link
Contributor

Oh ok, I will add it next week!

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

@raphael0202
Copy link
Author

@monsieurtanuki It's deployed in production :)

@monsieurtanuki
Copy link
Contributor

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

@raphodn
Copy link
Member

raphodn commented Nov 24, 2024

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

@monsieurtanuki
Copy link
Contributor

@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:

  • we would have slightly better price creation (the server would check if the type - when populated - matches the rest of the data)
  • we could filter more easily the prices (e.g. "show me the 'category' prices only")

@raphodn
Copy link
Member

raphodn commented Nov 26, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Status: Backlog
Status: 💬 To discuss and validate
Development

No branches or pull requests

4 participants