Skip to content

Commit

Permalink
fix: generate and build nutrient_levels.txt (without build_taxonomies…
Browse files Browse the repository at this point in the history
… in pull_request.yml) (#9886)

fix of #9883
  • Loading branch information
stephanegigandet authored Mar 7, 2024
1 parent 2dc9480 commit 7d7160c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ jobs:
- name: Download backend image from artifacts
uses: ishworkh/docker-image-artifact-download@v1
with:
image: "openfoodfacts-server/backend:dev"
image: "openfoodfacts-server/backend:dev"
- 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);

0 comments on commit 7d7160c

Please sign in to comment.