aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2012-05-15 10:56:30 +0100
committerStruan Donald <struan@exo.org.uk>2012-05-15 10:56:30 +0100
commit8a6bcedac3697e2c1c07c27bc0b42224b8f5ba16 (patch)
tree11425a253717e8ced02aef0fbc14460ed247bbb9
parentc12c7836af432302fe3805e6081df3182f0bc2b6 (diff)
check one report included in figures
-rw-r--r--t/app/controller/dashboard.t51
-rw-r--r--templates/web/default/dashboard/index.html14
2 files changed, 54 insertions, 11 deletions
diff --git a/t/app/controller/dashboard.t b/t/app/controller/dashboard.t
index eccbc0cde..93aee9a72 100644
--- a/t/app/controller/dashboard.t
+++ b/t/app/controller/dashboard.t
@@ -10,6 +10,7 @@ my $mech = FixMyStreet::TestMech->new;
my $test_user = 'council_user@example.com';
my $test_pass = 'password';
my $test_council = 2651;
+my $test_ward = 20723;
$mech->delete_user( $test_user );
my $user = FixMyStreet::App->model('DB::User')->create( {
@@ -17,6 +18,10 @@ my $user = FixMyStreet::App->model('DB::User')->create( {
password => $test_pass,
} );
+my $p_user = FixMyStreet::App->model('DB::User')->find_or_create( {
+ email => 'p_user@example.com'
+} );
+
$mech->not_logged_in_ok;
$mech->get_ok('/dashboard');
@@ -42,10 +47,8 @@ $mech->content_contains( 'Summary Statistics for City of Edinburgh' );
FixMyStreet::App->model('DB::Contact')->search( { area_id => $test_council } )
->delete;
-my $eight_weeks_ago = DateTime->now->subtract( weeks => 8 );
-
FixMyStreet::App->model('DB::Problem')->search( { council => $test_council } )
- ->update( { confirmed => $eight_weeks_ago } );
+ ->delete();
my @cats = qw( Grafitti Litter Potholes );
for my $contact ( @cats ) {
@@ -70,7 +73,18 @@ my $categories = scraper {
process "select[name=ward] > option", 'wards[]' => 'TEXT',
process "table[id=overview] > tr", 'rows[]' => scraper {
process 'td', 'cols[]' => 'TEXT'
- }
+ },
+ process "tr[id=total] > td", 'totals[]' => 'TEXT',
+ process "tr[id=fixed_council] > td", 'council[]' => 'TEXT',
+ process "tr[id=fixed_user] > td", 'user[]' => 'TEXT',
+ process "tr[id=total_fixed] > td", 'total_fixed[]' => 'TEXT',
+ process "tr[id=in_progress] > td", 'in_progress[]' => 'TEXT',
+ process "tr[id=planned] > td", 'planned[]' => 'TEXT',
+ process "tr[id=investigating] > td", 'investigating[]' => 'TEXT',
+ process "tr[id=marked] > td", 'marked[]' => 'TEXT',
+ process "tr[id=avg_marked] > td", 'avg_marked[]' => 'TEXT',
+ process "tr[id=avg_fixed] > td", 'avg_fixed[]' => 'TEXT',
+ process "tr[id=not_marked] > td", 'not_marked[]' => 'TEXT',
};
my $expected_cats = [ 'All', '-- Pick a category --', @cats, 'Other' ];
@@ -83,4 +97,33 @@ foreach my $row ( @{ $res->{rows} }[1 .. 11] ) {
}
}
+make_problem( { state => 'confirmed', conf_dt => DateTime->now } );
+
+$mech->get_ok('/dashboard');
+$res = $categories->scrape( $mech->content );
+
+is $res->{ totals }->[1], 1, 'Report in total';
+is $res->{ not_marked }->[1], 1, 'Report in not marked';
+
+sub make_problem {
+ my $args = shift;
+
+ my $p = FixMyStreet::App->model('DB::Problem')->create( {
+ title => 'a problem',
+ name => 'a user',
+ anonymous => 1,
+ detail => 'some detail',
+ state => $args->{state},
+ confirmed => $args->{conf_dt},
+ whensent => $args->{conf_dt},
+ council => $test_council,
+ postcode => 'EH99 1SP',
+ latitude => '51',
+ longitude => '1',
+ areas => $test_ward,
+ used_map => 0,
+ user_id => $p_user->id,
+ } );
+}
+
done_testing;
diff --git a/templates/web/default/dashboard/index.html b/templates/web/default/dashboard/index.html
index 66cbef5c5..f4d5e6814 100644
--- a/templates/web/default/dashboard/index.html
+++ b/templates/web/default/dashboard/index.html
@@ -46,7 +46,7 @@
'2' => [ "fixed_user", "User has marked as fixed" ]
};
FOR row IN rows %]
- <tr>
+ <tr id="[% row.value.0.replace('[^\w]+', '_' ) %]">
<th scope="row">[% row.value.1 %]</th>
<td>[% problems.wtd.${row.value.0} %]</td>
<td>[% problems.week.${row.value.0} %]</td>
@@ -55,7 +55,7 @@
</tr>
[% END %]
- <tr class='subtotal'>
+ <tr class='subtotal' id="total_fixed">
<th scope="row">Total marked as fixed</th>
<td>[% problems.wtd.${"fixed - council"} + problems.wtd.fixed_user %]</td>
<td>[% problems.week.${"fixed - council"} + problems.week.fixed_user %]</td>
@@ -71,7 +71,7 @@
};
wtd = 0, week = 0, weeks = 0, ytd = 0;
FOR row IN rows %]
- <tr>
+ <tr id="[% row.value.0.replace('[^\w]+', '_' ) %]">
<th scope="row">[% row.value.1 %]</th>
<td>[% problems.wtd.${row.value.0} %]</td>
<td>[% problems.week.${row.value.0} %]</td>
@@ -80,7 +80,7 @@
</tr>
[% END %]
- <tr class='subtotal'>
+ <tr class='subtotal' id="marked">
<th scope="row">Total marked</th>
<td>[% problems.wtd.${"in progress"} + problems.wtd.planned + problems.wtd.investigating %]</td>
<td>[% problems.week.${"in progress"} + problems.week.planned + problems.week.investigating %]</td>
@@ -88,7 +88,7 @@
<td>[% problems.ytd.${"in progress"} + problems.ytd.planned + problems.ytd.investigating %]</td>
</tr>
- <tr>
+ <tr id="avg_fixed">
<th scope="row">Average time to council marking fixed (days)</th>
<td>[% problems.wtd.time_to_fix %]</td>
<td>[% problems.week.time_to_fix %]</td>
@@ -96,7 +96,7 @@
<td>[% problems.ytd.time_to_fix %]</td>
</tr>
- <tr>
+ <tr id="avg_marked">
<th scope="row">Average time to first council state change (days)</th>
<td>[% problems.wtd.time_to_mark %]</td>
<td>[% problems.week.time_to_mark %]</td>
@@ -104,7 +104,7 @@
<td>[% problems.ytd.time_to_mark %]</td>
</tr>
- <tr class='subtotal'>
+ <tr class='subtotal' id="not_marked">
<th scope="row">Total not marked</th>
<td>[% problems.wtd.not_marked %]</td>
<td>[% problems.week.not_marked %]</td>