diff options
Diffstat (limited to 'perllib')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Reports.pm | 4 | ||||
-rw-r--r-- | perllib/FixMyStreet/TestMech.pm | 43 |
2 files changed, 46 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm index 37766db44..dd725be19 100644 --- a/perllib/FixMyStreet/App/Controller/Reports.pm +++ b/perllib/FixMyStreet/App/Controller/Reports.pm @@ -236,6 +236,7 @@ sub council_check : Private { type => $area_types, min_generation => $c->cobrand->area_min_generation ); + if (keys %$areas == 1) { ($c->stash->{council}) = values %$areas; return; @@ -318,7 +319,8 @@ sub load_and_group_problems : Private { my $page = $c->req->params->{p} || 1; my $where = { - state => [ FixMyStreet::DB::Result::Problem->visible_states() ] + non_public => 0, + state => [ FixMyStreet::DB::Result::Problem->visible_states() ] }; if ($c->stash->{ward}) { $where->{areas} = { 'like', '%,' . $c->stash->{ward}->{id} . ',%' }; diff --git a/perllib/FixMyStreet/TestMech.pm b/perllib/FixMyStreet/TestMech.pm index 2a49cc2f8..53ec7ad89 100644 --- a/perllib/FixMyStreet/TestMech.pm +++ b/perllib/FixMyStreet/TestMech.pm @@ -378,6 +378,49 @@ sub extract_update_metas { return \@metas; } +=head2 extract_problem_list + + $problems = $mech->extract_problem_list + +Returns an array ref of all problem titles on a page featuring standard issue lists + +=cut + +sub extract_problem_list { + my $mech = shift; + + my $result = scraper { + process 'ul.issue-list-a li a h4', 'problems[]', 'TEXT'; + }->scrape( $mech->response ); + + return $result->{ problems } || []; +} + +=head2 extract_report_stats + + $stats = $mech->extract_report_stats + +Returns a hash ref keyed by council name of all the council stats from the all reports +page. Each value is an array ref with the first element being the council name and the +rest being the stats in the order the appear in each row. + +=cut + +sub extract_report_stats { + my $mech = shift; + + my $result = scraper { + process 'tr[align=center]', 'councils[]' => scraper { + process 'td.title a', 'council', 'TEXT', + process 'td', 'stats[]', 'TEXT' + } + }->scrape( $mech->response ); + + my %councils = map { $_->{council} => $_->{stats} } @{ $result->{councils} }; + + return \%councils; +} + =head2 visible_form_values $hashref = $mech->visible_form_values( ); |