From 0580506d826846595f19480992d10bce66807734 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Mon, 19 Mar 2012 16:54:07 +0000 Subject: Factor FMS /reports templates back into default, tweak to show fixed and last updated date. --- perllib/FixMyStreet/App/Controller/Reports.pm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'perllib/FixMyStreet/App/Controller') diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm index e7620f755..dd6ecd9e3 100644 --- a/perllib/FixMyStreet/App/Controller/Reports.pm +++ b/perllib/FixMyStreet/App/Controller/Reports.pm @@ -341,9 +341,10 @@ sub load_and_group_problems : Private { { columns => [ 'id', 'council', 'state', 'areas', 'latitude', 'longitude', 'title', 'cobrand', - { duration => { extract => "epoch from current_timestamp-lastupdate" } }, - { age => { extract => "epoch from current_timestamp-confirmed" } }, - { confirmed => { extract => 'epoch from confirmed' } }, + #{ duration => { extract => "epoch from current_timestamp-lastupdate" } }, + #{ age => { extract => "epoch from current_timestamp-confirmed" } }, + { confirmed => { extract => 'epoch from confirmed' } }, + { lastupdate => { extract => 'epoch from lastupdate' } }, { photo => 'photo is not null' }, ], order_by => { -desc => 'lastupdate' }, @@ -355,9 +356,10 @@ sub load_and_group_problems : Private { my ( %problems, @pins ); my $re_councils = join('|', keys %{$c->stash->{areas_info}}); - my @cols = ( 'id', 'council', 'state', 'areas', 'latitude', 'longitude', 'title', 'cobrand', 'duration', 'age', 'confirmed', 'photo' ); + my @cols = ( 'id', 'council', 'state', 'areas', 'latitude', 'longitude', 'title', 'cobrand', 'confirmed', 'lastupdate', 'photo' ); while ( my @problem = $problems->next ) { my %problem = zip @cols, @problem; + $problem{is_fixed} = FixMyStreet::DB::Result::Problem->fixed_states()->{$problem{state}}; $c->log->debug( $problem{'cobrand'} . ', cobrand is ' . $c->cobrand->moniker ); if ( !$problem{council} ) { # Problem was not sent to any council, add to possible councils -- cgit v1.2.3 From daa508bcf8c193fc90786c628cdcca76abfedb30 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Mon, 19 Mar 2012 18:30:11 +0000 Subject: Ignore whensent last update time. --- perllib/FixMyStreet/App/Controller/Reports.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'perllib/FixMyStreet/App/Controller') diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm index dd6ecd9e3..9fb72121e 100644 --- a/perllib/FixMyStreet/App/Controller/Reports.pm +++ b/perllib/FixMyStreet/App/Controller/Reports.pm @@ -344,6 +344,7 @@ sub load_and_group_problems : Private { #{ duration => { extract => "epoch from current_timestamp-lastupdate" } }, #{ age => { extract => "epoch from current_timestamp-confirmed" } }, { confirmed => { extract => 'epoch from confirmed' } }, + { whensent => { extract => 'epoch from whensent' } }, { lastupdate => { extract => 'epoch from lastupdate' } }, { photo => 'photo is not null' }, ], @@ -356,7 +357,7 @@ sub load_and_group_problems : Private { my ( %problems, @pins ); my $re_councils = join('|', keys %{$c->stash->{areas_info}}); - my @cols = ( 'id', 'council', 'state', 'areas', 'latitude', 'longitude', 'title', 'cobrand', 'confirmed', 'lastupdate', 'photo' ); + my @cols = ( 'id', 'council', 'state', 'areas', 'latitude', 'longitude', 'title', 'cobrand', 'confirmed', 'whensent', 'lastupdate', 'photo' ); while ( my @problem = $problems->next ) { my %problem = zip @cols, @problem; $problem{is_fixed} = FixMyStreet::DB::Result::Problem->fixed_states()->{$problem{state}}; -- cgit v1.2.3 From bd9738d1e9cae14125d2e926bc7bfb87be186805 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Wed, 21 Mar 2012 00:20:12 +0000 Subject: If questionnaire says report remains open, show that on report page. --- perllib/FixMyStreet/App/Controller/Report.pm | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'perllib/FixMyStreet/App/Controller') diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index 59e3a4410..bb7c8dea0 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -51,7 +51,7 @@ sub display : Path('') : Args(1) { return $c->res->redirect( $c->uri_for($1), 301 ); } - $c->forward('load_problem_or_display_error', [ $id ] ); + $c->forward( 'load_problem_or_display_error', [ $id ] ); $c->forward( 'load_updates' ); $c->forward( 'format_problem_for_display' ); } @@ -88,7 +88,24 @@ sub load_updates : Private { { order_by => 'confirmed' } ); - $c->stash->{updates} = $updates; + my $questionnaires = $c->model('DB::Questionnaire')->search( + { + problem_id => $c->stash->{problem}->id, + whenanswered => { '!=', undef }, + old_state => 'confirmed', new_state => 'confirmed', + }, + { order_by => 'whenanswered' } + ); + + my @combined; + while (my $update = $updates->next) { + push @combined, [ $update->{confirmed}, $update ]; + } + while (my $update = $questionnaires->next) { + push @combined, [ $update->{whenanswered}, $update ]; + } + @combined = map { $_->[1] } sort { $a->[0] <=> $b->[0] } @combined; + $c->stash->{updates} = \@combined; return 1; } -- cgit v1.2.3 From f7c46612fd1ae32e738acfc084abb674d1c1487a Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Wed, 21 Mar 2012 00:33:41 +0000 Subject: Use correct method names. --- perllib/FixMyStreet/App/Controller/Report.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'perllib/FixMyStreet/App/Controller') diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index bb7c8dea0..afe180c29 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -99,10 +99,10 @@ sub load_updates : Private { my @combined; while (my $update = $updates->next) { - push @combined, [ $update->{confirmed}, $update ]; + push @combined, [ $update->confirmed, $update ]; } while (my $update = $questionnaires->next) { - push @combined, [ $update->{whenanswered}, $update ]; + push @combined, [ $update->whenanswered, $update ]; } @combined = map { $_->[1] } sort { $a->[0] <=> $b->[0] } @combined; $c->stash->{updates} = \@combined; -- cgit v1.2.3 From eba1039023271bac6178776f9e7d48b79a1c43e3 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Mon, 26 Mar 2012 18:58:24 +0100 Subject: Photos in report list on /my page, and only show cobranded reports. --- perllib/FixMyStreet/App/Controller/My.pm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'perllib/FixMyStreet/App/Controller') diff --git a/perllib/FixMyStreet/App/Controller/My.pm b/perllib/FixMyStreet/App/Controller/My.pm index 60e9dd09f..3de83b265 100644 --- a/perllib/FixMyStreet/App/Controller/My.pm +++ b/perllib/FixMyStreet/App/Controller/My.pm @@ -30,9 +30,16 @@ sub my : Path : Args(0) { my $pins = []; my $problems = {}; - my $rs = $c->user->problems->search( { + + my $params = { state => [ FixMyStreet::DB::Result::Problem->visible_states() ], - }, { + }; + $params = { + %{ $c->cobrand->problems_clause }, + %$params + } if $c->cobrand->problems_clause; + + my $rs = $c->user->problems->search( $params, { order_by => { -desc => 'confirmed' }, rows => 50 } )->page( $p_page ); -- cgit v1.2.3