diff options
-rw-r--r-- | conf/httpd.conf | 5 | ||||
-rw-r--r-- | perllib/FixMyStreet/App.pm | 4 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Around.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Contact.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/JSON.pm | 82 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Photo.pm | 2 | ||||
-rwxr-xr-x | perllib/FixMyStreet/App/Controller/Questionnaire.pm | 3 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/Update.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Reports.pm | 5 | ||||
-rwxr-xr-x | perllib/FixMyStreet/App/Controller/Rss.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Tokens.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Barnet.pm | 11 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Default.pm | 28 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Southampton.pm | 11 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/ResultSet/Problem.pm | 61 | ||||
-rw-r--r-- | perllib/Problems.pm | 149 | ||||
-rw-r--r-- | templates/web/default/front_stats.html | 3 |
19 files changed, 162 insertions, 216 deletions
diff --git a/conf/httpd.conf b/conf/httpd.conf index 4e8d8db3a..c8d6a6c0c 100644 --- a/conf/httpd.conf +++ b/conf/httpd.conf @@ -43,11 +43,6 @@ RewriteEngine on # RewriteLog /var/log/apache2/rewrite.log # RewriteLogLevel 3 -# End slashes goodbye -RewriteRule ^/admin/ - [L] -RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d -RewriteRule ^(.+)/$ $1 [R=permanent] - # Confirmation tokens # RewriteRule ^/[Aa]/([0-9A-Za-z]{16,18}).*$ /alert.cgi?token=$1 [QSA,L] # RewriteRule ^/[Cc]/([0-9A-Za-z]{16,18}).*$ /confirm.cgi?type=update;token=$1 [QSA,L] diff --git a/perllib/FixMyStreet/App.pm b/perllib/FixMyStreet/App.pm index 09a8609fe..811a40eb0 100644 --- a/perllib/FixMyStreet/App.pm +++ b/perllib/FixMyStreet/App.pm @@ -130,7 +130,7 @@ sub _get_cobrand { ? FixMyStreet::Cobrand->get_class_for_moniker($override_moniker) : FixMyStreet::Cobrand->get_class_for_host($host); - my $cobrand = $cobrand_class->new( { request => $c->req } ); + my $cobrand = $cobrand_class->new( { c => $c } ); return $cobrand; } @@ -177,7 +177,7 @@ sub setup_request { $c->log->debug( sprintf "Set lang to '%s' and cobrand to '%s'", $set_lang, $cobrand->moniker ); - Problems::set_site_restriction_with_cobrand_object($cobrand); + $c->model('DB::Problem')->set_restriction( $cobrand->site_restriction() ); Memcached::set_namespace( FixMyStreet->config('BCI_DB_NAME') . ":" ); diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm index aed56e58f..1e06beef1 100644 --- a/perllib/FixMyStreet/App/Controller/Around.pm +++ b/perllib/FixMyStreet/App/Controller/Around.pm @@ -130,7 +130,7 @@ sub load_partial : Private { || last; # load the related problem - my $report = $c->model("DB::Problem") # + my $report = $c->cobrand->problems # ->search( { id => $report_id, state => 'partial' } ) # ->first || last; diff --git a/perllib/FixMyStreet/App/Controller/Contact.pm b/perllib/FixMyStreet/App/Controller/Contact.pm index c74597f3b..bd7d415e7 100644 --- a/perllib/FixMyStreet/App/Controller/Contact.pm +++ b/perllib/FixMyStreet/App/Controller/Contact.pm @@ -63,7 +63,7 @@ sub determine_contact_type : Private { $update_id = undef unless $update_id && $update_id =~ /^[1-9]\d*$/; if ($id) { - my $problem = $c->model('DB::Problem')->find( + my $problem = $c->cobrand->problems->find( { id => $id }, { 'select' => [ diff --git a/perllib/FixMyStreet/App/Controller/JSON.pm b/perllib/FixMyStreet/App/Controller/JSON.pm index d3688f19a..37df98735 100644 --- a/perllib/FixMyStreet/App/Controller/JSON.pm +++ b/perllib/FixMyStreet/App/Controller/JSON.pm @@ -7,6 +7,7 @@ BEGIN { extends 'Catalyst::Controller'; } use JSON; use DateTime; use DateTime::Format::ISO8601; +use List::MoreUtils 'uniq'; =head1 NAME @@ -69,42 +70,53 @@ sub problems : Local { } # query the database - $c->stash->{response} = - $type eq 'new_problems' - ? Problems::created_in_interval( $start_date, $end_date ) - : Problems::fixed_in_interval( $start_date, $end_date ); -} + my ( $state, $date_col ); + if ( $type eq 'new_problems' ) { + $state = 'confirmed'; + $date_col = 'created'; + } elsif ( $type eq 'fixed_problems' ) { + $state = 'fixed'; + $date_col = 'lastupdate'; + } + + my $one_day = DateTime::Duration->new( days => 1 ); + my @problems = $c->cobrand->problems->search( { + $date_col => { + '>=' => $start_dt, + '<=' => $end_dt + $one_day, + }, + state => $state, + }, { + columns => [ + 'id', 'title', 'council', 'category', + 'detail', 'name', 'anonymous', 'confirmed', + 'whensent', 'service', + ] + } ); + + my @councils; + foreach my $problem (@problems) { + $problem->name( '' ) if $problem->anonymous == 1; + $problem->service( 'Web interface' ) if $problem->service eq ''; + if ($problem->council) { + (my $council = $problem->council) =~ s/\|.*//g; + my @council_ids = split /,/, $council; + push(@councils, @council_ids); + $problem->council( \@council_ids ); + } + } + @councils = uniq @councils; + my $areas_info = mySociety::MaPit::call('areas', \@councils); + foreach my $problem (@problems) { + if ($problem->council) { + my @council_names = map { $areas_info->{$_}->{name} } @{$problem->council} ; + $problem->council( join(' and ', @council_names) ); + } + } -# If we convert this code to be fully DBIC based then the following snippet is a -# good start. The roadblock to doing it fully is the 'site_restriction' in the -# SQL which is currently provided as SQL, rather than something that could be -# easily added to the DBIC query. The hardest cobrand to change would be the -# cities - so perhaps do it after we know wether that needs to be kept or not. -# -# my $state = -# $type eq 'new_problems' ? 'confirmed' -# : $type eq 'fixed_problems' ? 'fixed_problems' -# : die; -# -# my $one_day = DateTime::Duration->new( days => 1 ); -# -# my $problems = $c->model('DB::Problem')->search( -# { -# created => { -# '>=' => $start_dt, -# '<=' => $end_dt + $one_day, -# }, -# state => $state, -# # ------ add is site_restriction here ------- -# }, -# { -# columns => [ -# 'id', 'title', 'council', 'category', -# 'detail', 'name', 'anonymous', 'confirmed', -# 'whensent', 'service', -# ] -# } -# ); + @problems = map { { $_->get_columns } } @problems; + $c->stash->{response} = \@problems; +} sub end : Private { my ( $self, $c ) = @_; diff --git a/perllib/FixMyStreet/App/Controller/Photo.pm b/perllib/FixMyStreet/App/Controller/Photo.pm index 7b2a04e4b..3c6255f3a 100644 --- a/perllib/FixMyStreet/App/Controller/Photo.pm +++ b/perllib/FixMyStreet/App/Controller/Photo.pm @@ -40,7 +40,7 @@ sub index :Path :Args(0) { photo => { '!=', undef }, } ); } else { - @photo = $c->model('DB::Problem')->search( { + @photo = $c->cobrand->problems->search( { id => $id, state => [ 'confirmed', 'fixed', 'partial' ], photo => { '!=', undef }, diff --git a/perllib/FixMyStreet/App/Controller/Questionnaire.pm b/perllib/FixMyStreet/App/Controller/Questionnaire.pm index 58c88979d..b4c9ade92 100755 --- a/perllib/FixMyStreet/App/Controller/Questionnaire.pm +++ b/perllib/FixMyStreet/App/Controller/Questionnaire.pm @@ -108,8 +108,7 @@ sub submit_creator_fixed : Private { $c->detach('missing_problem'); } - my $problem = $c->model('DB::Problem')->find( { id => - $c->stash->{problem} } ); + my $problem = $c->cobrand->problems->find( { id => $c->stash->{problem} } ); # you should not be able to answer questionnaires about problems # that you've not submitted diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index c4138f4d6..0fe1834e7 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -62,7 +62,7 @@ sub load_problem_or_display_error : Private { my $problem # = $id =~ m{\D} # is id non-numeric? ? undef # ...don't even search - : $c->model('DB::Problem')->find( { id => $id } ); + : $c->cobrand->problems->find( { id => $id } ); # check that the problem is suitable to show. if ( !$problem || $problem->state eq 'unconfirmed' ) { diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index 5c52d0257..4d9bcd672 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -289,7 +289,7 @@ sub initialize_report : Private { || last; # load the related problem - $report = $c->model("DB::Problem") # + $report = $c->cobrand->problems # ->search( { id => $id, state => 'partial' } ) # ->first; diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm index fe512d03c..2ca9245ad 100644 --- a/perllib/FixMyStreet/App/Controller/Report/Update.pm +++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm @@ -99,7 +99,7 @@ sub setup_page : Private { my ( $self, $c ) = @_; my $problem = - $c->model('DB::Problem')->find( { id => $c->req->param('id') } ); + $c->cobrand->problems->find( { id => $c->req->param('id') } ); return unless $problem; diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm index 993cd752e..c64bc9054 100644 --- a/perllib/FixMyStreet/App/Controller/Reports.pm +++ b/perllib/FixMyStreet/App/Controller/Reports.pm @@ -246,8 +246,7 @@ sub load_problems : Private { my ( $self, $c ) = @_; my $where = { - state => [ 'confirmed', 'fixed' ], - %{ Problems::site_restriction() } + state => [ 'confirmed', 'fixed' ] }; if ($c->stash->{ward}) { $where->{areas} = { 'like', '%' . $c->stash->{ward}->{id} . '%' }; # FIXME Check this is secure @@ -255,7 +254,7 @@ sub load_problems : Private { $where->{areas} = { 'like', '%' . $c->stash->{council}->{id} . '%' }; } my $current_timestamp = Problems::current_timestamp(); - my $problems = $c->model('DB::Problem')->search( + my $problems = $c->cobrand->problems->search( $where, { columns => [ diff --git a/perllib/FixMyStreet/App/Controller/Rss.pm b/perllib/FixMyStreet/App/Controller/Rss.pm index f41ffe217..4c048b56d 100755 --- a/perllib/FixMyStreet/App/Controller/Rss.pm +++ b/perllib/FixMyStreet/App/Controller/Rss.pm @@ -30,7 +30,7 @@ sub updates : LocalRegex('^(\d+)$') { my ( $self, $c ) = @_; my $id = $c->req->captures->[0]; - my $problem = $c->model('DB::Problem')->find( { id => $id } ); + my $problem = $c->cobrand->problems->find( { id => $id } ); # FIXME Put these 404/410 checks in central place - Report.pm does it too. if ( !$problem || $problem->state eq 'unconfirmed' ) { diff --git a/perllib/FixMyStreet/App/Controller/Tokens.pm b/perllib/FixMyStreet/App/Controller/Tokens.pm index 92a44e756..c75fcc9ee 100644 --- a/perllib/FixMyStreet/App/Controller/Tokens.pm +++ b/perllib/FixMyStreet/App/Controller/Tokens.pm @@ -33,7 +33,7 @@ sub confirm_problem : Path('/P') { # Load the problem my $problem_id = $auth_token->data; - my $problem = $c->model('DB::Problem')->find( { id => $problem_id } ) + my $problem = $c->cobrand->problems->find( { id => $problem_id } ) || $c->detach('token_error'); $c->stash->{problem} = $problem; diff --git a/perllib/FixMyStreet/Cobrand/Barnet.pm b/perllib/FixMyStreet/Cobrand/Barnet.pm index f68d61256..6468fd934 100644 --- a/perllib/FixMyStreet/Cobrand/Barnet.pm +++ b/perllib/FixMyStreet/Cobrand/Barnet.pm @@ -12,6 +12,13 @@ sub site_restriction { return ( "and council='2489'", 'barnet', { council => '2489' } ); } +sub problems { + my $self = shift; + return $self->{c}->model('DB::Problem')->search( { + council => '2489' + } ); +} + sub base_url { my $base_url = mySociety::Config::get('BASE_URL'); if ( $base_url !~ /barnet/ ) { @@ -52,8 +59,8 @@ sub council_check { } my $url = 'http://www.fixmystreet.com/'; $url .= 'alert' if $context eq 'alert'; - $url .= '?pc=' . URI::Escape::uri_escape( $self->{request}->param('pc') ) - if $self->{request}->param('pc'); + $url .= '?pc=' . URI::Escape::uri_escape( $self->{c}->req->param('pc') ) + if $self->{c}->req->param('pc'); my $error_msg = "That location is not covered by Barnet. Please visit <a href=\"$url\">the main FixMyStreet site</a>."; return ( 0, $error_msg ); diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm index b002dd7f2..208ac6643 100644 --- a/perllib/FixMyStreet/Cobrand/Default.pm +++ b/perllib/FixMyStreet/Cobrand/Default.pm @@ -11,9 +11,9 @@ use mySociety::MaPit; =head2 new my $cobrand = $class->new; - my $cobrand = $class->new( { request => $c->req } ); + my $cobrand = $class->new( { c => $c } ); -Create a new cobrand object, optionally setting the web request. +Create a new cobrand object, optionally setting the context. You probably shouldn't need to do this and should get the cobrand object via a method in L<FixMyStreet::Cobrand> instead. @@ -69,6 +69,18 @@ sub path_to_web_templates { return FixMyStreet->path_to( 'templates/web', $self->moniker ); } +=head1 problems + +Returns a ResultSet of Problems, restricted to a subset if we're on a cobrand +that only wants some of the data. + +=cut + +sub problems { + my $self = shift; + return $self->{c}->model('DB::Problem'); +} + =head1 site_restriction Return a site restriction clause and a site key if the cobrand uses a subset of @@ -208,8 +220,8 @@ Return recent problems on the site. =cut sub recent { - my $self = shift; - return Problems::recent(@_); + my ( $self ) = @_; + return $self->problems->recent(); } =item shorten_recency_if_new_greater_than_fixed @@ -231,18 +243,18 @@ can then format. =cut sub front_stats_data { - my $self = shift; + my ( $self ) = @_; my $recency = '1 week'; my $shorter_recency = '3 days'; - my $fixed = Problems::recent_fixed(); + my $fixed = $self->problems->recent_fixed(); my $updates = Problems::number_comments(); - my $new = Problems::recent_new($recency); + my $new = $self->problems->recent_new( $recency ); if ( $new > $fixed && $self->shorten_recency_if_new_greater_than_fixed ) { $recency = $shorter_recency; - $new = Problems::recent_new($recency); + $new = $self->problems->recent_new( $recency ); } my $stats = { diff --git a/perllib/FixMyStreet/Cobrand/Southampton.pm b/perllib/FixMyStreet/Cobrand/Southampton.pm index aa9945c00..77032baa8 100644 --- a/perllib/FixMyStreet/Cobrand/Southampton.pm +++ b/perllib/FixMyStreet/Cobrand/Southampton.pm @@ -12,6 +12,13 @@ sub site_restriction { return ( "and council='2567'", 'southampton', { council => '2567' } ); } +sub problems { + my $self = shift; + return $self->{c}->model('DB::Problem')->search( { + council => '2567' + } ); +} + sub base_url { my $base_url = mySociety::Config::get('BASE_URL'); if ($base_url !~ /southampton/) { @@ -51,8 +58,8 @@ sub council_check { } my $url = 'http://www.fixmystreet.com/'; $url .= 'alert' if $context eq 'alert'; - $url .= '?pc=' . URI::Escape::uri_escape_utf8($self->{request}->param('pc')) - if $self->{request}->param('pc'); + $url .= '?pc=' . URI::Escape::uri_escape_utf8($self->{c}->req->param('pc')) + if $self->{c}->req->param('pc'); my $error_msg = "That location is not covered by Southampton. Please visit <a href=\"$url\">the main FixMyStreet site</a>."; return ( 0, $error_msg ); diff --git a/perllib/FixMyStreet/DB/ResultSet/Problem.pm b/perllib/FixMyStreet/DB/ResultSet/Problem.pm index 835ab1b45..af850ecd0 100644 --- a/perllib/FixMyStreet/DB/ResultSet/Problem.pm +++ b/perllib/FixMyStreet/DB/ResultSet/Problem.pm @@ -4,6 +4,67 @@ use base 'DBIx::Class::ResultSet'; use strict; use warnings; +my $site_restriction; +my $site_key; + +sub set_restriction { + my ( $rs, $sql, $key, $restriction ) = @_; + $site_key = $key; + $site_restriction = $restriction; +} + +# Front page statistics + +sub recent_fixed { + my $rs = shift; + my $key = "recent_fixed:$site_key"; + my $result = Memcached::get($key); + unless ($result) { + $result = $rs->search( { + state => 'fixed', + lastupdate => { '>', \"current_timestamp-'1 month'::interval" }, + } )->count; + Memcached::set($key, $result, 3600); + } + return $result; +} + +sub recent_new { + my ( $rs, $interval ) = @_; + (my $key = $interval) =~ s/\s+//g; + $key = "recent_new:$site_key:$key"; + my $result = Memcached::get($key); + unless ($result) { + $result = $rs->search( { + state => [ 'confirmed', 'fixed' ], + confirmed => { '>', \"current_timestamp-'$interval'::interval" }, + } )->count; + Memcached::set($key, $result, 3600); + } + return $result; +} + +# Front page recent lists + +sub recent { + my ( $rs ) = @_; + my $key = "recent:$site_key"; + my $result = Memcached::get($key); + unless ($result) { + $result = $rs->search( { + state => [ 'confirmed', 'fixed' ] + }, { + columns => [ 'id', 'title' ], + order_by => { -desc => 'confirmed' }, + rows => 5, + } )->count; + Memcached::set($key, $result, 3600); + } + return $result; +} + +# Admin functions + sub timeline { my ( $rs, $restriction ) = @_; diff --git a/perllib/Problems.pm b/perllib/Problems.pm index c31fdd507..a6eb0c519 100644 --- a/perllib/Problems.pm +++ b/perllib/Problems.pm @@ -21,41 +21,12 @@ use mySociety::MaPit; my $site_restriction = ''; my $site_key = 0; -my $site_restriction_hash = {}; - -sub site_restriction { - return $site_restriction_hash; -} - -# Set the site restrictions using the new cobrand style - no need to special -# case 'fixmystreet' as default cobrand takes care of that. -sub set_site_restriction_with_cobrand_object { - my $cobrand = shift; - - my $cobrand_data = $cobrand->extra_data; - ( $site_restriction, $site_key, $site_restriction_hash ) = - $cobrand->site_restriction($cobrand_data); -} sub current_timestamp { my $current_timestamp = dbh()->selectrow_array('select ms_current_timestamp()'); return "'$current_timestamp'::timestamp"; } -# Front page statistics - -sub recent_fixed { - my $key = "recent_fixed:$site_key"; - my $result = Memcached::get($key); - unless ($result) { - $result = dbh()->selectrow_array("select count(*) from problem - where state='fixed' and lastupdate>" . current_timestamp() . "-'1 month'::interval - $site_restriction"); - Memcached::set($key, $result, 3600); - } - return $result; -} - sub number_comments { my $key = "number_comments:$site_key"; my $result = Memcached::get($key); @@ -73,20 +44,6 @@ sub number_comments { return $result; } -sub recent_new { - my $interval = shift; - (my $key = $interval) =~ s/\s+//g; - $key = "recent_new:$site_key:$key"; - my $result = Memcached::get($key); - unless ($result) { - $result = dbh()->selectrow_array("select count(*) from problem - where state in ('confirmed','fixed') and confirmed>" . current_timestamp() . "-'$interval'::interval - $site_restriction"); - Memcached::set($key, $result, 3600); - } - return $result; -} - # Front page recent lists sub recent_photos { @@ -128,51 +85,6 @@ sub recent_photos { return $out; } -sub recent { - my $key = "recent:$site_key"; - my $result = Memcached::get($key); - unless ($result) { - $result = select_all("select id,title from problem - where state in ('confirmed', 'fixed') - $site_restriction - order by confirmed desc limit 5"); - Memcached::set($key, $result, 3600); - } - return $result; -} - -# sub front_stats { -# my ($q) = @_; -# my $fixed = Problems::recent_fixed(); -# my $updates = Problems::number_comments(); -# my $new = Problems::recent_new('1 week'); -# (my $new_pretty = $new) =~ s/(?<=\d)(?=(?:\d\d\d)+$)/,/g; -# my $new_text = sprintf(mySociety::Locale::nget('<big>%s</big> report in past week', -# '<big>%s</big> reports in past week', $new), $new_pretty); -# if ($q->{site} ne 'emptyhomes' && $new > $fixed) { -# $new = Problems::recent_new('3 days'); -# ($new_pretty = $new) =~ s/(?<=\d)(?=(?:\d\d\d)+$)/,/g; -# $new_text = sprintf(mySociety::Locale::nget('<big>%s</big> report recently', '<big>%s</big> reports recently', $new), $new_pretty); -# } -# (my $fixed_pretty = $fixed) =~ s/(?<=\d)(?=(?:\d\d\d)+$)/,/g; -# (my $updates_pretty = $updates) =~ s/(?<=\d)(?=(?:\d\d\d)+$)/,/g; -# -# my $out = ''; -# $out .= $q->h2(_('FixMyStreet updates')); -# my $lastmo = ''; -# if ($q->{site} ne 'emptyhomes'){ -# $lastmo = $q->div(sprintf(mySociety::Locale::nget("<big>%s</big> fixed in past month", "<big>%s</big> fixed in past month", $fixed), $fixed), $fixed_pretty); -# } -# $out .= $q->div({-id => 'front_stats'}, -# $q->div($new_text), -# ($q->{site} ne 'emptyhomes' ? $q->div(sprintf(mySociety::Locale::nget("<big>%s</big> fixed in past month", "<big>%s</big> fixed in past month", $fixed), $fixed_pretty)) : ''), -# $q->div(sprintf(mySociety::Locale::nget("<big>%s</big> update on reports", -# "<big>%s</big> updates on reports", $updates), $updates_pretty)) -# ); -# return $out; -# -# } - # Problems around a location sub around_map { @@ -236,67 +148,6 @@ sub fetch_problem { return $p; } -# API functions - -sub problems_matching_criteria { - my ($criteria, @params) = @_; - my $problems = select_all( - "select id, title, council, category, detail, name, anonymous, - confirmed, whensent, service - from problem - $criteria - $site_restriction", @params); - - my @councils; - foreach my $problem (@$problems){ - if ($problem->{anonymous} == 1){ - $problem->{name} = ''; - } - if ($problem->{service} eq ''){ - $problem->{service} = 'Web interface'; - } - if ($problem->{council}) { - $problem->{council} =~ s/\|.*//g; - my @council_ids = split /,/, $problem->{council}; - push(@councils, @council_ids); - $problem->{council} = \@council_ids; - } - } - my $areas_info = mySociety::MaPit::call('areas', \@councils); - foreach my $problem (@$problems){ - if ($problem->{council}) { - my @council_names = map { $areas_info->{$_}->{name} } @{$problem->{council}} ; - $problem->{council} = join(' and ', @council_names); - } - } - return $problems; -} - -sub fixed_in_interval { - my ($start_date, $end_date) = @_; - my $criteria = "where state='fixed' and date_trunc('day',lastupdate)>=? and -date_trunc('day',lastupdate)<=?"; - return problems_matching_criteria($criteria, $start_date, $end_date); -} - -sub created_in_interval { - my ($start_date, $end_date) = @_; - my $criteria = "where state='confirmed' and date_trunc('day',created)>=? and -date_trunc('day',created)<=?"; - return problems_matching_criteria($criteria, $start_date, $end_date); -} - -=item data_sharing_notification_start - -Returns the unix datetime when the T&Cs that explicitly allow for users' data to be displayed -on other sites. - -=cut - -sub data_sharing_notification_start { - return 1255392000; -} - # Report functions =item council_problems WARD COUNCIL diff --git a/templates/web/default/front_stats.html b/templates/web/default/front_stats.html index 847df2497..385414768 100644 --- a/templates/web/default/front_stats.html +++ b/templates/web/default/front_stats.html @@ -4,6 +4,7 @@ # 'Template::Plugin::Number::Format' %] +<h2>[% loc('FixMyStreet updates') %]</h2> [% stats = c.cobrand.front_stats_data(); @@ -37,7 +38,9 @@ <div id="front_stats"> <div>[% tprintf( new_text, stats.new ) | comma %]</div> + [% IF c.cobrand.moniker != 'emptyhomes' %] <div>[% tprintf( fixed_text, stats.fixed ) | comma %]</div> + [% END %] <div>[% tprintf( updates_text, stats.updates ) | comma %]</div> </div> |