diff options
author | Matthew Somerville <matthew@mysociety.org> | 2012-05-09 15:56:38 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2012-05-09 15:56:38 +0100 |
commit | c46ef588de465a79f1475f4e1da5e756c9554853 (patch) | |
tree | 35c9c6cbfd8585e49fa6d634925e8e2aaeb27c45 | |
parent | 42436d60599e1daabcac1390f328a8841f396d90 (diff) |
Lists of reports by age.
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Dashboard.pm | 30 | ||||
-rw-r--r-- | templates/web/default/dashboard/index.html | 12 |
2 files changed, 32 insertions, 10 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Dashboard.pm b/perllib/FixMyStreet/App/Controller/Dashboard.pm index d1e8da01d..1f2d003fe 100644 --- a/perllib/FixMyStreet/App/Controller/Dashboard.pm +++ b/perllib/FixMyStreet/App/Controller/Dashboard.pm @@ -116,12 +116,28 @@ sub index : Path : Args(0) { # List of reports underneath summary table - #$c->stash->{q_state} = $c->req->param('state') || ''; - #if ( $c->stash->{q_state} eq 'fixed' ) { - # $where{'problem.state'} = [ FixMyStreet::DB::Result::Problem->fixed_states() ]; - #} elsif ( $c->stash->{q_state} ) { - # $where{'problem.state'} = $c->stash->{q_state} - #} + $c->stash->{q_state} = $c->req->param('state') || ''; + if ( $c->stash->{q_state} eq 'fixed' ) { + $prob_where->{state} = [ FixMyStreet::DB::Result::Problem->fixed_states() ]; + } elsif ( $c->stash->{q_state} ) { + $prob_where->{state} = $c->stash->{q_state}; + } + my $params = { + %$prob_where, + 'me.confirmed' => { '>=', DateTime->now->subtract( days => 30 ) }, + }; + my @problems = $c->cobrand->problems->search( $params )->all; + my %problems; + foreach (@problems) { + if ($_->confirmed >= DateTime->now->subtract(days => 7)) { + push @{$problems{1}}, $_; + } elsif ($_->confirmed >= DateTime->now->subtract(days => 14)) { + push @{$problems{2}}, $_; + } else { + push @{$problems{3}}, $_; + } + } + $c->stash->{lists} = \%problems; } sub updates_search : Private { @@ -171,7 +187,7 @@ sub updates_search : Private { join => 'problem' } )->first; - $counts{$col} = int( $comments->get_column('time') / 60 / 60 / 24 + 0.5 ); + $counts{$col} = int( ($comments->get_column('time')||0) / 60 / 60 / 24 + 0.5 ); } $counts{fixed_user} = $c->model('DB::Comment')->search( diff --git a/templates/web/default/dashboard/index.html b/templates/web/default/dashboard/index.html index 1f733c8c5..0f2bb13ff 100644 --- a/templates/web/default/dashboard/index.html +++ b/templates/web/default/dashboard/index.html @@ -133,12 +133,18 @@ <th scope="col">14-30 days old</th> </tr> <tr> - <td><ul><li></li></ul></td> - <td><ul><li></li></ul></td> - <td><ul><li></li></ul></td> + <td><ul>[% INCLUDE list, list = lists.1 %]</ul></td> + <td><ul>[% INCLUDE list, list = lists.2 %]</ul></td> + <td><ul>[% INCLUDE list, list = lists.3 %]</ul></td> </tr> </table> </form> [% INCLUDE 'footer.html' %] + +[% BLOCK list %] +[% FOR p IN list %] +<li><a href="/report/[% p.id %]">[% p.title | html %]</a></li> +[% END %] +[% END %] |