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: generate and build nutrient_levels.txt #9885

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ jobs:
uses: ishworkh/docker-image-artifact-download@v1
with:
image: "openfoodfacts-server/backend:dev"
- name: build taxonomies (should use cache)
run: make build_taxonomies
- name: tests
run: |
make codecov_prepare
Expand Down
5 changes: 4 additions & 1 deletion lib/ProductOpener/Food.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2470,7 +2470,10 @@ sub create_nutrients_level_taxonomy() {
}
}

open(my $OUT, ">:encoding(UTF-8)", "$data_root/taxonomies/nutrient_levels.txt");
print STDERR "generate $data_root/taxonomies/nutrient_levels.txt \n";

open(my $OUT, ">:encoding(UTF-8)", "$data_root/taxonomies/nutrient_levels.txt")
or die("Can't write $data_root/taxonomies/nutrient_levels.txt: $!");
print $OUT <<TXT
# nutrient levels taxonomy generated automatically by Food.pm from nutrients taxonomy + language translations (.po files)

Expand Down
2 changes: 1 addition & 1 deletion lib/ProductOpener/Tags.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2467,7 +2467,7 @@ sub retrieve_tags_taxonomy ($tagtype) {
if (!-e "$data_root/taxonomies/$file.result.sto") {
print("Building $file on the fly\n");
# Nutrients levels taxonomy is generated from the nutrients taxonomy + language translations in Food.pm
# nutrients_levels.txt is not checked in the taxonomy directory and will be generated by build_lang.pl
# nutrient_levels.txt is not checked in the taxonomy directory and will be generated by build_lang.pl
# To avoid circular dependencies, we don't build it on the fly when Tags.pm is loaded.
if (($tagtype eq "nutrient_levels") and (!-e "$data_root/taxonomies/$file.txt")) {
print("Skipping nutrient_levels.txt as it is has not been generated by build_lang.pl yet\n");
Expand Down
3 changes: 2 additions & 1 deletion scripts/build_lang.pl
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@

# Nutrients level taxonomy file is built using languages
create_nutrients_level_taxonomy();

# and generate corresponding taxonomy
build_tags_taxonomy('nutrients_levels', 1);
build_tags_taxonomy('nutrient_levels', 1);

exit(0);

Loading