aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/DB/ResultSet/Problem.pm
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2011-06-09 08:53:45 +0100
committerStruan Donald <struan@exo.org.uk>2011-06-09 08:53:45 +0100
commit79edaacb35d12c0f7867aab899e016805e99268b (patch)
tree2e38a01d88e57445e06c8697cef742fab7b173d4 /perllib/FixMyStreet/DB/ResultSet/Problem.pm
parenta7fb8b236afb7f7f25008acdafdc5b0585e78b74 (diff)
parentba0bd42476b93908529f63bb8b71135ebf7a86ca (diff)
Merge branch 'migrate_to_catalyst' of ssh://git.mysociety.org/data/git/public/fixmystreet into migrate_to_catalyst
Diffstat (limited to 'perllib/FixMyStreet/DB/ResultSet/Problem.pm')
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Problem.pm23
1 files changed, 23 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/DB/ResultSet/Problem.pm b/perllib/FixMyStreet/DB/ResultSet/Problem.pm
index af850ecd0..ea146cd54 100644
--- a/perllib/FixMyStreet/DB/ResultSet/Problem.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/Problem.pm
@@ -63,6 +63,29 @@ sub recent {
return $result;
}
+# Problems around a location
+
+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', 'confirmed'
+ ],
+ };
+ $attr->{rows} = $limit if $limit;
+
+ my $q = {
+ state => [ 'confirmed', 'fixed' ],
+ latitude => { '>=', $min_lat, '<', $max_lat },
+ longitude => { '>=', $min_lon, '<', $max_lon },
+ };
+ $q->{'current_timestamp - lastupdate'} = { '<', \"'$interval'::interval" };
+
+ my @problems = mySociety::Locale::in_gb_locale { $rs->search( $q, $attr )->all };
+ return \@problems;
+}
+
# Admin functions
sub timeline {