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

Nutrients should accept a String #908

Closed
g123k opened this issue Apr 16, 2024 · 5 comments
Closed

Nutrients should accept a String #908

g123k opened this issue Apr 16, 2024 · 5 comments

Comments

@g123k
Copy link
Contributor

g123k commented Apr 16, 2024

Hi everyone,

Currently, the Nutriments class is based on double? for values.
However, the server may also have a "-" value.

What's the best way to handle this change?
Because I think, it will clearly break the implementation.

Example from the API:

        "nutriments": {
            "energy": 1,
            "energy-kj": 1,
            "energy-kj_100g": 1,
            "energy-kj_serving": 1,
            "energy-kj_unit": "kJ",
            "energy-kj_value": 1,
            "energy_100g": 1,
            "energy_serving": 1,
            "energy_unit": "kJ",
            "energy_value": 1,
            "fiber_modifier": "-",
            "proteins_modifier": "-"
        },

At the same type, we should also support #584

Any suggestion @monsieurtanuki?

@g123k g123k changed the title Nutriments should allow String Nutriments should accept a String Apr 16, 2024
@monsieurtanuki
Copy link
Contributor

@g123k I still haven't understood the added value of '-' compared to null. I cannot be helpful here.

@g123k
Copy link
Contributor Author

g123k commented Apr 16, 2024

- is one of the possible values, but the server also always to input that kind of thing:
> 1
< 1
or ~ 1

I know your point on - 😇, but we should at least support the others, especially for the SDK.

@stephanegigandet
Copy link
Contributor

We use '-' instead of an empty string, or an undefined / null value to make it explicitly clear that we know there is no value specified for this nutrient on the packaging. When we import or export data as CSV for instance, using '-' makes it possible to differentiate nutrients for which we don't know anything (maybe it is on the packaging but it has not been entered yet) and nutrients that we know are not specified.

@monsieurtanuki
Copy link
Contributor

It's better dealt with by #910, with both a double and a modifier, instead of a single String.
We may close this issue as redundant, then.

@g123k g123k changed the title Nutriments should accept a String Nutrients should accept a String Apr 22, 2024
@g123k
Copy link
Contributor Author

g123k commented Apr 22, 2024

It's better dealt with by #910, with both a double and a modifier, instead of a single String. We may close this issue as redundant, then.

+1, closing this one

@g123k g123k closed this as completed Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants