aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/canonicalise-csv5
-rw-r--r--perllib/Page.pm11
-rw-r--r--perllib/Problems.pm20
3 files changed, 16 insertions, 20 deletions
diff --git a/bin/canonicalise-csv b/bin/canonicalise-csv
index 17b952769..c745ef459 100755
--- a/bin/canonicalise-csv
+++ b/bin/canonicalise-csv
@@ -6,7 +6,7 @@
# Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org. WWW: http://www.mysociety.org
#
-# $Id: canonicalise-csv,v 1.3 2007-02-02 12:23:06 matthew Exp $
+# $Id: canonicalise-csv,v 1.4 2009-02-16 18:56:44 matthew Exp $
use strict;
require 5.8.0;
@@ -26,7 +26,8 @@ BEGIN {
}
my %councils;
-open(FP, "$FindBin::Bin/../data/councils.csv");
+open(FP, "$FindBin::Bin/../data/councils.csv")
+ or die "Can't read councils.csv: $!\n";
while (<FP>) {
s/\r?\n//g;
my ($name, $email) = split /,/;
diff --git a/perllib/Page.pm b/perllib/Page.pm
index 88eb9a754..abc136d08 100644
--- a/perllib/Page.pm
+++ b/perllib/Page.pm
@@ -6,7 +6,7 @@
# Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: Page.pm,v 1.139 2009-02-14 11:30:49 matthew Exp $
+# $Id: Page.pm,v 1.140 2009-02-16 18:56:44 matthew Exp $
#
package Page;
@@ -397,10 +397,11 @@ sub map_pins {
$pins .= Page::display_pin($q, $px, $py, $col);
}
- mySociety::Locale::push('en-gb');
- my ($lat, $lon) = mySociety::GeoUtil::national_grid_to_wgs84($mid_e, $mid_n, 'G');
- my $dist = mySociety::Gaze::get_radius_containing_population($lat, $lon, 200000);
- mySociety::Locale::pop();
+ my $dist;
+ mySociety::Locale::in_gb_locale {
+ my ($lat, $lon) = mySociety::GeoUtil::national_grid_to_wgs84($mid_e, $mid_n, 'G');
+ $dist = mySociety::Gaze::get_radius_containing_population($lat, $lon, 200000);
+ };
$dist = int($dist*10+0.5)/10;
my $limit = 20; # - @$current_map;
diff --git a/perllib/Problems.pm b/perllib/Problems.pm
index bf7fa8029..eafcc1ccf 100644
--- a/perllib/Problems.pm
+++ b/perllib/Problems.pm
@@ -6,7 +6,7 @@
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: Problems.pm,v 1.10 2009-02-14 11:30:49 matthew Exp $
+# $Id: Problems.pm,v 1.11 2009-02-16 18:56:44 matthew Exp $
#
package Problems;
@@ -129,22 +129,19 @@ sub recent {
sub around_map {
my ($min_e, $max_e, $min_n, $max_n, $interval) = @_;
- mySociety::Locale::push('en-gb');
- my $ret = select_all(
+ mySociety::Locale::in_gb_locale { select_all(
"select id,title,easting,northing,state from problem
where state in ('confirmed', 'fixed')
and easting>=? and easting<? and northing>=? and northing<? " .
($interval ? " and ms_current_timestamp()-lastupdate < '$interval'::interval" : '') .
" $site_restriction
order by created desc", $min_e, $max_e, $min_n, $max_n);
- mySociety::Locale::pop();
- return $ret;
+ };
}
sub nearby {
my ($dist, $ids, $limit, $mid_e, $mid_n, $interval) = @_;
- mySociety::Locale::push('en-gb');
- my $ret = select_all(
+ mySociety::Locale::in_gb_locale { select_all(
"select id, title, easting, northing, distance, state
from problem_find_nearby(?, ?, $dist) as nearby, problem
where nearby.problem_id = problem.id " .
@@ -152,21 +149,18 @@ sub nearby {
" and state in ('confirmed', 'fixed')" . ($ids ? ' and id not in (' . $ids . ')' : '') . "
$site_restriction
order by distance, created desc limit $limit", $mid_e, $mid_n);
- mySociety::Locale::pop();
- return $ret;
+ }
}
sub fixed_nearby {
my ($dist, $mid_e, $mid_n) = @_;
- mySociety::Locale::push('en-gb');
- my $ret = select_all(
+ mySociety::Locale::in_gb_locale { select_all(
"select id, title, easting, northing, distance
from problem_find_nearby(?, ?, $dist) as nearby, problem
where nearby.problem_id = problem.id and state='fixed'
$site_restriction
order by lastupdate desc", $mid_e, $mid_n);
- mySociety::Locale::pop();
- return $ret;
+ }
}
# Fetch an individual problem