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

Fix null value in various places: app, website, documentation, exports #9426

Open
10 tasks
CharlesNepote opened this issue Nov 28, 2023 · 0 comments
Open
10 tasks
Labels
Data export We export data nightly as CSV, MongoDB… See: https://world.openfoodfacts.org/data ⭐ top issue Top issue.

Comments

@CharlesNepote
Copy link
Member

The zero (0) is ambiguous on Open Food Facts:

  • sometimes it means the value of the field is zero
  • sometimes some users want to say the value does not exist on the packaging

An empty value is also be ambiguous:

  • sometimes some users want to say the value does not exist on the packaging
  • sometimes some users want to say the value is 0
  • sometimes nobody has completed this value: it is just meaning that people didn't have time to do so

The Null value is solving these ambiguities. It allows to make a clear difference between:

  • the zero value: this product contains no fibers
  • the empty value: we don't have completed this information yet
  • the non-existence of the value: Null means that this information does not exist on the packaging

Null can be implemented differently depending on the situation.

User interface

When people are filling product data, it should be easy to express the Null value.

Mobile: see Nutritional values: allow to input an empty value

Web: we have chosen to use the hyphen '-' to express the null value: it is short and language agnostic; it is part of the ASCII and many keyboards should have it, as it is also used to express "minor" in mathematics

  • Document the hyphen meaning in web interfaces
  • Document the hyphen meaning on the wiki
  • Highlight empty fields and add an interrogation when the field is empty
  • When a hyphen is completed somewhere it should increase the completeness value (to be verified)

Exports

CSV export

CSV does have a convention to express Null. Currently CSV export does not export hyphens as is. There are deleted. TODO:

  • Allow hyphens in CSV exports
  • Document it

MongoDB export

In MongoDB, as the main database systems, the null value does exist, represented by null. For example: { "sugar": null } is valid in MongoDB even if sugar is an integer. In our MongoDB export, the hyphen is wrongly interpreted. A field filled with a hyphen produce a new field with a _modifier suffix. Example: if the user enters fiber: "-" then the system:

  • does not store a fiber value
  • but rather creates a "fiber_modifier":"-" (this is the same behavior as for the < sign).

JSONL export

In JSON the null value does exist, represented by null. For example: { "sugar_100g": null } is valid in JSON even if sugar_100g is an integer. In out JSONL export, the hyphen is wrongly interpreted as "fiber_modifier":"-". This is not documented

API

The API should have the same behavior as the MongoDB and JSONL exports.

@github-actions github-actions bot added the ⭐ top issue Top issue. label Dec 9, 2023
@CharlesNepote CharlesNepote added the Data export We export data nightly as CSV, MongoDB… See: https://world.openfoodfacts.org/data label Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Data export We export data nightly as CSV, MongoDB… See: https://world.openfoodfacts.org/data ⭐ top issue Top issue.
Projects
Status: To discuss and validate
Development

No branches or pull requests

1 participant