-
-
Notifications
You must be signed in to change notification settings - Fork 400
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: Statistics for packagings materials by categories #8613
Conversation
Co-authored-by: Alex Garel <alex@garel.org>
…s.tt.json Co-authored-by: Alex Garel <alex@garel.org>
Codecov Report
@@ Coverage Diff @@
## main #8613 +/- ##
==========================================
- Coverage 48.79% 48.60% -0.19%
==========================================
Files 114 117 +3
Lines 21475 21747 +272
Branches 4804 4852 +48
==========================================
+ Hits 10478 10571 +93
- Misses 9705 9880 +175
- Partials 1292 1296 +4
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Some minor changes proposed.
lib/ProductOpener/PackagingStats.pm
Outdated
# Export packaging components of all products to a CSV file | ||
my $filehandle; | ||
my $filename = "$www_root/data/$name.csv"; | ||
open($filehandle, ">:encoding(UTF-8)", $filename) | ||
or die("Could not write " . $filename . " : $!\n"); | ||
my $csv = Text::CSV->new( | ||
{ | ||
eol => "\n", | ||
sep => "\t", | ||
quote_space => 0, | ||
binary => 1 | ||
} | ||
) or die "Cannot use CSV: " . Text::CSV->error_diag(); | ||
|
||
# Print the header line with fields names | ||
$csv->print( | ||
$filehandle, | ||
[ | ||
"code", "countries_tags", "categories_tags", "number_of_units", | ||
"shape", "material", "parent_material", "recycling", | ||
"weight", "weight_measured", "weight_specified", "quantity_per_unit" | ||
] | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: typically the kind of thing I would like to have in a separate method, to avoid hindering code read. (something like: my ($filehandle, $csv) = init_products_packaging_components_csv()
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, will do.
Co-authored-by: Alex Garel <alex@garel.org>
Co-authored-by: Alex Garel <alex@garel.org>
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
This PR:
e.g. for yoghurts: