diff options
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Dashboard.pm | 21 | ||||
-rw-r--r-- | perllib/FixMyStreet/Geocode.pm | 6 | ||||
-rw-r--r-- | perllib/FixMyStreet/Geocode/OSM.pm | 2 |
3 files changed, 27 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Dashboard.pm b/perllib/FixMyStreet/App/Controller/Dashboard.pm index f961660c0..7f4a4bb27 100644 --- a/perllib/FixMyStreet/App/Controller/Dashboard.pm +++ b/perllib/FixMyStreet/App/Controller/Dashboard.pm @@ -157,6 +157,27 @@ sub index : Path : Args(0) { %$prob_where, 'me.confirmed' => { '>=', $dtf->format_datetime( $now->clone->subtract( days => 30 ) ) }, }; + + if ( $c->get_param('start_date') or $c->get_param('end_date') ) { + my @parts; + if ($c->get_param('start_date')) { + my $date = $dtf->parse_datetime( $c->get_param('start_date') ); + push @parts, { '>=', $dtf->format_datetime( $date ) }; + $c->stash->{start_date} = $c->get_param('start_date'); + } + if ($c->get_param('end_date')) { + my $date = $dtf->parse_datetime( $c->get_param('end_date') ); + push @parts, { '<=', $dtf->format_datetime( $date ) }; + $c->stash->{end_date} = $c->get_param('end_date'); + } + + if (scalar @parts == 2) { + $params->{'me.confirmed'} = [ -and => $parts[0], $parts[1] ]; + } else { + $params->{'me.confirmed'} = $parts[0]; + } + } + my $problems_rs = $c->cobrand->problems->to_body($body)->search( $params ); my @problems = $problems_rs->all; diff --git a/perllib/FixMyStreet/Geocode.pm b/perllib/FixMyStreet/Geocode.pm index dd1adfe71..aeac0ab6d 100644 --- a/perllib/FixMyStreet/Geocode.pm +++ b/perllib/FixMyStreet/Geocode.pm @@ -79,8 +79,12 @@ sub cache { $url .= '&' . $args if $args; $ua->timeout(15); $js = LWP::Simple::get($url); - $cache_dir->mkpath; + # The returned data is not correctly decoded if the content type is + # e.g. application/json. Which all of our geocoders return. + # uncoverable branch false + $js = decode_utf8($js) if !utf8::is_utf8($js); if ($js && (!$re || $js !~ $re) && !FixMyStreet->config('STAGING_SITE')) { + $cache_dir->mkpath; # uncoverable statement # uncoverable statement $cache_file->spew_utf8($js); } diff --git a/perllib/FixMyStreet/Geocode/OSM.pm b/perllib/FixMyStreet/Geocode/OSM.pm index f165963d7..020be3c2a 100644 --- a/perllib/FixMyStreet/Geocode/OSM.pm +++ b/perllib/FixMyStreet/Geocode/OSM.pm @@ -41,7 +41,7 @@ sub string { if $params->{bounds}; $query_params{countrycodes} = $params->{country} if $params->{country}; - $url .= join('&', map { "$_=$query_params{$_}" } keys %query_params); + $url .= join('&', map { "$_=$query_params{$_}" } sort keys %query_params); my $js = FixMyStreet::Geocode::cache('osm', $url); if (!$js) { |