aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2013-01-08 16:00:44 +0000
committerMatthew Somerville <matthew@mysociety.org>2013-01-08 16:16:02 +0000
commit4e8afc117eae6d315392fcd2d12bc38a8330bd14 (patch)
tree1924fa84607f32f7ac8751f60e4b27ae50fc0890
parentee8d80ddaa0cf1cd82db8741b45692091fed5544 (diff)
Update database fetching to fetch needed data for previous commit.
-rw-r--r--perllib/FixMyStreet/App/Controller/Reports.pm4
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Nearby.pm7
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Problem.pm5
3 files changed, 3 insertions, 13 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm
index bf65fe1d5..eab308054 100644
--- a/perllib/FixMyStreet/App/Controller/Reports.pm
+++ b/perllib/FixMyStreet/App/Controller/Reports.pm
@@ -374,7 +374,7 @@ sub load_and_group_problems : Private {
{ confirmed => { extract => 'epoch from confirmed' } },
{ whensent => { extract => 'epoch from whensent' } },
{ lastupdate => { extract => 'epoch from lastupdate' } },
- { photo => 'photo is not null' },
+ 'photo', 'extra',
],
order_by => { -desc => 'lastupdate' },
rows => $c->cobrand->reports_per_page,
@@ -384,7 +384,7 @@ sub load_and_group_problems : Private {
$problems = $problems->cursor; # Raw DB cursor for speed
my ( %problems, @pins );
- my @cols = ( 'id', 'bodies_str', 'state', 'areas', 'latitude', 'longitude', 'title', 'cobrand', 'confirmed', 'whensent', 'lastupdate', 'photo' );
+ my @cols = ( 'id', 'bodies_str', 'state', 'areas', 'latitude', 'longitude', 'title', 'cobrand', 'confirmed', 'whensent', 'lastupdate', 'photo', 'extra' );
while ( my @problem = $problems->next ) {
my %problem = zip @cols, @problem;
$problem{is_fixed} = FixMyStreet::DB::Result::Problem->fixed_states()->{$problem{state}};
diff --git a/perllib/FixMyStreet/DB/ResultSet/Nearby.pm b/perllib/FixMyStreet/DB/ResultSet/Nearby.pm
index 4039ec6e7..91c44d5f4 100644
--- a/perllib/FixMyStreet/DB/ResultSet/Nearby.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/Nearby.pm
@@ -21,12 +21,7 @@ sub nearby {
} if $c->cobrand->problems_clause;
my $attrs = {
- join => 'problem',
- columns => [
- 'problem.id', 'problem.title', 'problem.latitude',
- 'problem.longitude', 'distance', 'problem.state',
- 'problem.created', 'problem.confirmed', { 'problem.photo' => 'problem.photo is not null' },
- ],
+ prefetch => 'problem',
bind => [ $mid_lat, $mid_lon, $dist ],
order_by => [ 'distance', { -desc => 'created' } ],
rows => $limit,
diff --git a/perllib/FixMyStreet/DB/ResultSet/Problem.pm b/perllib/FixMyStreet/DB/ResultSet/Problem.pm
index a694c45f2..6cecdea7e 100644
--- a/perllib/FixMyStreet/DB/ResultSet/Problem.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/Problem.pm
@@ -93,7 +93,6 @@ sub _recent {
$query->{photo} = { '!=', undef } if $photos;
my $attrs = {
- columns => [ 'id', 'title', 'created', 'confirmed', 'state' ],
order_by => { -desc => 'coalesce(confirmed, created)' },
rows => $num,
};
@@ -136,10 +135,6 @@ sub around_map {
my ( $rs, $min_lat, $max_lat, $min_lon, $max_lon, $interval, $limit ) = @_;
my $attr = {
order_by => { -desc => 'created' },
- columns => [
- 'id', 'title', 'latitude', 'longitude', 'state', 'created', 'confirmed',
- { photo => 'photo is not null' },
- ],
};
$attr->{rows} = $limit if $limit;