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

Sending null from the SDK? #944

Closed
CharlesNepote opened this issue Jun 24, 2024 · 2 comments
Closed

Sending null from the SDK? #944

CharlesNepote opened this issue Jun 24, 2024 · 2 comments

Comments

@CharlesNepote
Copy link
Member

Copy/pasting a discussion with a user of the dart package:
Me:

  1. about the energy: you should not add a computed value for energy, for many reasons: depending on the countries, energy is not computed the same way (between 4.2 and 4.4 kJ per kcal); in some countries (eg. the USA 😉) products only use calories (we do compute kJ when kCal are entered, but it should be the decision of each player; we provide computed energy through the API as an independent field energy_100g)
  2. if you enter a new value for kCal and the user has not entered a value for kJ, you should reset the value of kJ (because this one is now probably false)
    (edited)

Them: "For 1 & 2, how should we go about resetting kJ? From the data quality report it seemed like our prior approach of not including kJ in the payload does not reset it. Does sending an explicit null in the dart SDK reset it?"

@monsieurtanuki
Copy link
Contributor

@CharlesNepote In the dart code we don't compute anything related to nutrients, like energy or sodium.

We can unset a nutrient value by setting explicitly a null value.
I've just managed to

  • reset both kcal and kj (100g) by setting both of them to null (nutriments.setValue(Nutrient.energyKJ, perSize, null);)
  • then set kcal to 1 (now on the server, kcal=1, kj=null)
  • then set kj to 1 (now on the server, kcal=1, kj=1)

Don't know if that answers all your questions.

@monsieurtanuki
Copy link
Contributor

Closing as the questions seem to be answered.
Feel free to reopen and ask even more precise questions if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants