diff options
author | Struan Donald <struan@exo.org.uk> | 2017-11-30 15:23:22 +0000 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2017-12-15 17:35:53 +0000 |
commit | 9931b8aac55df6baef69cee76f34d76bc08d293c (patch) | |
tree | 9b2ced85970854030f8ab34b8eef52535baf4fcc /perllib/FixMyStreet/App/Controller/Reports.pm | |
parent | af7a457bfaed2ba143aaeccfc7ccf2b8d443e22d (diff) |
[fixmystreet.com] CSV download from marketing page
Limited to most recent 100 rows and not full data.
Factor the two CSV generations together.
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Reports.pm')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Reports.pm | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm index 724fc7fbd..ec7a192b3 100644 --- a/perllib/FixMyStreet/App/Controller/Reports.pm +++ b/perllib/FixMyStreet/App/Controller/Reports.pm @@ -468,12 +468,51 @@ sub summary : Private { $c->forward('/dashboard/construct_rs_filter'); + if ( $c->get_param('csv') ) { + $c->detach('export_summary_csv'); + } + $c->forward('/dashboard/generate_grouped_data'); $c->forward('/dashboard/generate_body_response_time'); $c->stash->{template} = 'reports/summary.html'; } +sub export_summary_csv : Private { + my ( $self, $c ) = @_; + + $c->stash->{csv} = { + problems => $c->stash->{problems_rs}->search_rs({}, { + rows => 100, + order_by => { '-desc' => 'me.confirmed' }, + }), + headers => [ + 'Report ID', + 'Title', + 'Category', + 'Created', + 'Confirmed', + 'Status', + 'Latitude', 'Longitude', + 'Query', + 'Report URL', + ], + columns => [ + 'id', + 'title', + 'category', + 'created_pp', + 'confirmed_pp', + 'state', + 'latitude', 'longitude', + 'postcode', + 'url', + ], + filename => 'fixmystreet-data.csv', + }; + $c->forward('/dashboard/generate_csv'); +} + =head2 check_canonical_url Given an already found (case-insensitively) body, check what URL |