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

feat: add support for product quantity and packaging weights in search graphs #8963

Merged
merged 9 commits into from
Sep 7, 2023

Conversation

stephanegigandet
Copy link
Contributor

@stephanegigandet stephanegigandet commented Sep 6, 2023

Discussed in last packagings call: now that we have packaging weights, we could create graphs (histograms or scatter plots) using the packaging weights, so that it's easy to see distributions and view the corresponding products.

  • Added product_quantity + packaging weights fields (for main materials: all, glass, paper, plastics, metals etc. with for each either the total packaging weight, the weight per 100g, or the weight % compared to the other materials)
  • Small refactor of search graphs in order to remove duplicate code (and avoid adding more)

image

Part of

@stephanegigandet stephanegigandet requested a review from a team as a code owner September 6, 2023 13:42
@github-actions github-actions bot added Translations We use a non-standard version of GetText, lack language variants support translate.openfoodfacts.org Display labels Sep 6, 2023
@teolemon teolemon added the 📦 Packaging https://wiki.openfoodfacts.org/Category:Recycling label Sep 6, 2023
@stephanegigandet
Copy link
Contributor Author

Added very basic support for NOVA + Eco-Score score (which seems to go above 100, maybe we should cap it)

image

Copy link
Member

@alexgarel alexgarel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks.

lib/ProductOpener/Display.pm Outdated Show resolved Hide resolved
lib/ProductOpener/Display.pm Outdated Show resolved Hide resolved
lib/ProductOpener/Display.pm Show resolved Hide resolved
return ($title, $unit, $unit2, $allow_decimals);
}

sub display_scatter_plot ($graph_ref, $products_ref) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a POD would be good !

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding one

lib/ProductOpener/Display.pm Show resolved Hide resolved
lib/ProductOpener/Display.pm Outdated Show resolved Hide resolved
lib/ProductOpener/Display.pm Show resolved Hide resolved
lib/ProductOpener/Display.pm Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Sep 6, 2023

Codecov Report

Merging #8963 (8551469) into main (a0ba9d4) will increase coverage by 7.84%.
Report is 8 commits behind head on main.
The diff coverage is 4.46%.

@@            Coverage Diff             @@
##             main    #8963      +/-   ##
==========================================
+ Coverage   38.16%   46.01%   +7.84%     
==========================================
  Files          59       64       +5     
  Lines       19079    19818     +739     
  Branches     4653     4798     +145     
==========================================
+ Hits         7282     9119    +1837     
+ Misses      10720     9512    -1208     
- Partials     1077     1187     +110     
Files Changed Coverage Δ
lib/ProductOpener/Display.pm 11.22% <4.46%> (+1.34%) ⬆️

... and 33 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@teolemon teolemon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks very much for the Eco-Score, in addition to NOVA

@sonarcloud
Copy link

sonarcloud bot commented Sep 6, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@stephanegigandet stephanegigandet merged commit a96392b into main Sep 7, 2023
14 checks passed
@stephanegigandet stephanegigandet deleted the search-packagings branch September 7, 2023 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Display 📦 Packaging https://wiki.openfoodfacts.org/Category:Recycling Translations We use a non-standard version of GetText, lack language variants support translate.openfoodfacts.org
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

4 participants