Giter VIP home page Giter VIP logo

openfoodfacts-hungergames-react's Introduction

Hunger Game: One click categorizer for Open Food Facts

Requirements:

Setup:

  • yarn install
  • yarn start

To test the ingredients part, add ?type=ingredients to the url To test the nutrition part, add ?type=nutrition to the url

Libraries:

  • React
  • Foundation 5 (CSS, same as on OFF main site)
  • axios (http calls)

APIs:

OFF APIs and Robotoff

Build

  • yarn build

Use a simple webpack config to bundle in a single file (build/bundle.min.js) and facilitate integration in OFF main site

Countries list

  • yarn countries

Statically generated via from static.openfoodfacts.org

openfoodfacts-hungergames-react's People

Contributors

alexfauquette avatar arnaudbarre avatar dependabot-preview[bot] avatar dependabot[bot] avatar hangy avatar raphael0202 avatar teolemon avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

openfoodfacts-hungergames-react's Issues

How to test?

In the readme file, could you explain a little bit how to test the app?

(Sorry I don't know much about react.)

Add a nutrition facts input game

image

Add a simple little game that takes suspicious nutrition tables and propose them for review.

  • only the main nutrients are proposed
  • there's a box with the current value (or lack thereoff)
  • there a button to confirmate the value (request sent to server with new value)
  • there's a button to trash the value and validate (request sent to server with empty value)

Empty nutrition tables: https://world.openfoodfacts.org/state/photos-validated/state/nutrition-facts-to-be-completed/1.json?fields=code,images

Add an edition counter

I'm sure it would greatly improve the addiction -- as in OpenSolarMap (unfortunatly broken at that time, see Google Images).

The counter wouldn't have to store data server side. It could only be provided by a session cookie.

Add more prominent links for signed in users?

Currently, I only accidentally found this via the mobile app - it's great :)

I'm clever enough to have worked out the URL; however being able to access this from the normal web UI easily would be beneficial

No questions left UI should present the selection controls

Reproduce steps:

  • Filter by a specific criteria - Country: Australia, Categories
  • Wait for the UI to load

image

Expected:

  • I can easily navigate back or widen my search criteria

Actual:

  • I have to reload the whole UI, which does not retain my previous selections.

Hunger Games hammers the server with queries when there's no insight left

Hunger Games hammers the server with queries when there's no insight left to validate

you can reproduce it by going to : https://world.openfoodfacts.org/hunger-game?value_tag=carrefour and opening the debugging console, and looking at network requests

ip - - [21/Jan/2020:11:21:41 +0100] "GET /cgi/display.pl?api/v0/product/3760003785157.json?fields=product_name HTTP/1.0" 200 142 "https://world.openfoodfacts.org/hunger-game?value_tag=la-roumaniere" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36"
ip - - [21/Jan/2020:11:21:41 +0100] "GET /cgi/display.pl?api/v0/product/3760003782217.json?fields=product_name HTTP/1.0" 200 72 "https://world.openfoodfacts.org/hunger-game?value_tag=la-roumaniere" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36"
ip - - [21/Jan/2020:11:21:41 +0100] "GET /cgi/display.pl?api/v0/product/3760003780961.json?fields=product_name HTTP/1.0" 200 114 "https://world.openfoodfacts.org/hunger-game?value_tag=la-roumaniere" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36"
ip - - [21/Jan/2020:11:21:41 +0100] "GET /cgi/display.pl?api/v0/product/3760003782187.json?fields=product_name HTTP/1.0" 200 129 "https://world.openfoodfacts.org/hunger-game?value_tag=la-roumaniere" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36"
ip - - [21/Jan/2020:11:21:41 +0100] "GET /cgi/display.pl?api/v0/product/3760003782217.json?fields=product_name HTTP/1.0" 200 72 "https://world.openfoodfacts.org/hunger-game?value_tag=la-roumaniere" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36"
ip - - [21/Jan/2020:11:21:41 +0100] "GET /cgi/display.pl?api/v0/product/3760003780961.json?fields=product_name HTTP/1.0" 200 114 "https://world.openfoodfacts.org/hunger-game?value_tag=la-roumaniere" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36"

Barcode display?

Why display the barcode of the product? It wastes some place (sometimes we have to scroll).

The name of the product could be linked to the product page.

Or if it's for debugging purpose (screenshot gives the barcode product), the barcode could be smaller, on the same line as the title.

image

"No image available" in a different color?

Sometimes I'm waiting for the product image and I realise later that there is "no image available".

"No image available" should be in another color. I suggest a "soft" color such as "chocolate", not red nor blue to avoid confusion with links.

image

Improve common category mismatches

I've noticed mismatches with:

  • Mixed Vegetables
  • Olive Oil -> Is this Sardines in Olive Oil?; while en:Olive oils exists
  • Whole Almonds -> Is this Whole Almond Puree? (Possibly fixed)

... particularly in the US dataset.

Consider adding some kind of weighting to choose more popular categories, or inline editing for users to override selections?

Edit: Possibly related to openfoodfacts/robotoff#51

Get new insights after toggling selection

Describe the bug
Insight filter is only applied after the loaded questions are exhausted.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://de.openfoodfacts.org/hunger-game
  2. See that all insight types are selected
  3. Unselect the type of insight of the question that is currently displayed
  4. Observe that the same question is still displayed

Expected behavior
The current question should not be displayed any more. The insight filter should be applied immediately (possibly throttled to not spam robotoff with questions), so that I don't have to answer questions that I currently don't want to answer.

Yarn complaining with a recent version of Node

[1/4] ๐Ÿ”  Resolving packages...
warning react-scripts > [email protected]: Way too old
warning react-scripts > react-app-polyfill > [email protected]: core-js@<3.0 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
warning react-scripts > webpack-dev-server > chokidar > [email protected]: One of your dependencies needs to upgrade to fsevents v2: 1) Proper nodejs v10+ support 2) No more fetching binaries from AWS, smaller package size
warning react-scripts > workbox-webpack-plugin > babel-runtime > [email protected]: core-js@<3.0 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
warning react-scripts > workbox-webpack-plugin > workbox-build > [email protected]: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
warning react-scripts > eslint > file-entry-cache > flat-cache > [email protected]: CircularJSON is in maintenance only, flatted is its successor.
warning react-scripts > jest > jest-cli > jest-haste-map > sane > [email protected]: One of your dependencies needs to upgrade to fsevents v2: 1) Proper nodejs v10+ support 2) No more fetching binaries from AWS, smaller package size
warning react-scripts > jest > jest-cli > prompts > [email protected]: Please upgrade to kleur@3 or migrate to 'ansi-colors' if you prefer the old syntax. Visit <https://github.com/lukeed/kleur/releases/tag/v3.0.0\> for migration path(s).
warning react-scripts > jest > jest-cli > jest-config > babel-core > babel-register > [email protected]: core-js@<3.0 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
warning react-scripts > workbox-webpack-plugin > workbox-build > joi > [email protected]: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
warning react-scripts > workbox-webpack-plugin > workbox-build > joi > [email protected]: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
warning react-scripts > workbox-webpack-plugin > workbox-build > joi > topo > [email protected]: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
warning react-scripts > jest > jest-cli > jest-environment-jsdom > jsdom > [email protected]: use String.prototype.padStart()

Fetching 5 random products appears to present many repeats

image

I feel like this is a combination of:

  • Selects from API use only a "first page" of results or similar
  • Asynchronous writes are slower than the subsequent calls to the API; so results are double presented
  • The API call/writes appear to be causing moderate load - doing a few batches of answers can result in ~30 loading time. Unclear if its just this app or other overnight processes happening.

Edit;

Buttons are not clear

Why n, k and o in "No(n)", "Not sure (k)" and "Yes (o)"?

Is it related to keyboard actions? (Selecting n or k or o does nothing indeed.)

"Not sure": I would add "skip": "Not sure, skip". The word "skip" explain next action if I'm not sure. I'm not afraid of selecting "Not sure, skip" because I understand it does nothing, it just skip the product.

Game uses country code from the domain as language

If you open https://ch.openfoodfacts.org/hunger-game, then the game will call the robotoff API with lang=ch. The language should be de in that case. There's probably other cases where the country code does not equal the language code. Also, OFF can be called for a country with different language. Due to that, for example, de-ru.openfoodfacts.org should display products from Germany in Russian language.

https://github.com/openfoodfacts/openfoodfacts-hungergames/blob/1c74f58f066bc21c9ec20bc0122329219c97125f/src/Questions/index.js#L15-L22

Hunger Games shouldn't save answers as roboto-app user

Rationale

  • Sometimes I answer too quickly and I need to get back to a particular product: it's easier to find it while being saved by my user account
  • I like to know how much products I have done during a Hunger Game session.

(Robotoff might be responsible but I open the ticket where I observ the problem.)

Show the existing categories, to avoid adding an imprecise category.

Related #32

Example: https://au.openfoodfacts.org/product/26174921/dairy-fine-peanuts -

I was prompted by an insight with:

Does the product belong to this category? Nuts and their products
It's very tempting to say "well, sort of" if you don't know it has a more precise category on it already.

If I saw the categories:

Categories: Snacks, Sweet snacks, Confectioneries, Chocolate candies, Bonbons, Chocolate covered nuts, Chocolate covered peanuts

I would more accurately apply the insight.

Product language detection

Would it be possible to detect the language of an ingredient and product? An ingredient white list (the taxonomy) can be used for the detection. If the ingredient language does not match the ingredient list language, the new language can be added to the product. This new language can then be filled by the system, and removed from the other field. I noticed that there are many products that have the wrong language, so this would repair them. Hunger games can offer a way to confirm this.

Nutrients are not properly saved by the nutrition game (probably because of ,)

https://world.openfoodfacts.org/product/3077315890760/dijon-senf-original
Those were the values I entered that have been passed on to the next product, but without units. Perhaps the start of an explanation ?
image

nutriment_energy=1280&%2Cnutriment_fat=23&%2Cnutriment_saturated-fat=13&%2Cnutriment_carbohydrates=20&%2Cnutriment_sugars=18&%2Cnutriment_proteins=5.0&%2Cnutriment_salt=0.3&nutriment_energy_unit=Kj&nutriment_fat_unit=g&nutriment_saturated-fat_unit=g&nutriment_carbohydrates_unit=g&nutriment_sugars_unit=g&nutriment_proteins_unit=g&nutriment_salt_unit=g&code=8718906808232

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.