diff options
author | Dave Arter <davea@mysociety.org> | 2015-11-18 15:35:51 +0000 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2015-11-18 15:35:51 +0000 |
commit | 8fad976f9b12cc36e317d01aee3cd4b20270f512 (patch) | |
tree | 3c42a79ad2ffff4050ad1d88ef448c3f6fdf8edc | |
parent | b334c3bd8043385efb1c882755f8ad207ebc8bb9 (diff) |
[Zurich] Generate the CSV header the same way as normal rows
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Zurich.pm | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm index 018d42a5f..bda5310fc 100644 --- a/perllib/FixMyStreet/Cobrand/Zurich.pm +++ b/perllib/FixMyStreet/Cobrand/Zurich.pm @@ -1117,9 +1117,37 @@ sub admin_stats { ] } ); - my $body = "Report ID,Created,Sent to Agency,Last Updated,E,N,Category,Status,Closure Status,UserID,External Body,Time Spent,Title,Detail,Media URL,Interface Used,Council Response\n"; + my @fields = ( + 'Report ID', + 'Created', + 'Sent to Agency', + 'Last Updated', + 'E', + 'N', + 'Category', + 'Status', + 'Closure Status', + 'UserID', + 'External Body', + 'Time Spent', + 'Title', + 'Detail', + 'Media URL', + 'Interface Used', + 'Council Response' + ); + + my $body = ""; require Text::CSV; my $csv = Text::CSV->new({ binary => 1 }); + + if ($csv->combine(@fields)) { + $body .= $csv->string . "\n"; + } + else { + $body .= sprintf "{{error emitting CSV line: %s}}\n", $csv->error_diag; + } + while ( my $report = $problems->next ) { my $external_body; my $body_name = ""; |