Skip to content

Commit

Permalink
Add links to food bank pages
Browse files Browse the repository at this point in the history
  • Loading branch information
slowe committed Jul 24, 2024
1 parent 1d43262 commit e4a9637
Show file tree
Hide file tree
Showing 4 changed files with 658 additions and 656 deletions.
8 changes: 5 additions & 3 deletions pipelines/society/foodbanks.pl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ BEGIN
# Get a new copy of the food bank data
SaveFromURL("https://www.givefood.org.uk/api/2/foodbanks/",$fbkfile);

my (@items,$i,$lookup,$pcon,$totals,$name);
my (@items,$i,$lookup,$pcon,$totals,$name,$namesafe);

# Read in the HexJSON and build the lookup
my $hexjson = LoadJSON($hexfile);
Expand Down Expand Up @@ -52,9 +52,11 @@ BEGIN


open(my $fh,">:utf8",$outfile) || error("Unable to save to <cyan>$outfile<none>\n");
print $fh "Code,Constituency,Region,Food banks\n";
print $fh "Code,Constituency,Slug,Region,Food banks\n";
foreach $name (sort{ $lookup->{$a}{'id'} cmp $lookup->{$b}{'id'} }(keys(%{$lookup}))){
print $fh ($lookup->{$name}{'id'}||"").",".($name =~ /\,/ ? "\"$name\"" : $name).",".($lookup->{$name}{'region'}||"").",".($lookup->{$name}{'total'}||"0")."\n";
$namesafe = lc($name);
$namesafe =~ s/ /\-/g;
print $fh ($lookup->{$name}{'id'}||"").",".($name =~ /\,/ ? "\"$name\"" : $name).",".($namesafe =~ /\,/ ? "\"$namesafe\"" : $namesafe).",".($lookup->{$name}{'region'}||"").",".($lookup->{$name}{'total'}||"0")."\n";
}
close($fh);
msg("Saved to <cyan>$outfile<none>\n");
Expand Down
Loading

0 comments on commit e4a9637

Please sign in to comment.