aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2017-08-15 14:02:48 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2017-08-18 09:43:42 +0100
commit918dc67ad5e3001e7d871b23beae4d36a028641f (patch)
tree1c1cc5d24200814b31b850d0eeab92d8b161a273
parentf1859bc10aaa153568ea866142c8535cbf769b87 (diff)
Allow co-ords to be supplied to fixture script.
-rwxr-xr-xbin/fixmystreet.com/fixture21
1 files changed, 15 insertions, 6 deletions
diff --git a/bin/fixmystreet.com/fixture b/bin/fixmystreet.com/fixture
index 912d34aab..6df675f7c 100755
--- a/bin/fixmystreet.com/fixture
+++ b/bin/fixmystreet.com/fixture
@@ -27,6 +27,7 @@ my ($opt, $usage) = describe_options(
[ 'name:s', "Name of body to use (defaults to MapIt area name)" ],
[ 'empty', "Empty all tables of the database first" ],
[ 'commit', "Actually commit changes to the database" ],
+ [ 'coords=s', "Co-ordinates to use instead of example postcode" ],
[ 'help', "print usage message and exit", { shortcircuit => 1 } ],
);
print($usage->text), exit if $opt->help;
@@ -108,8 +109,16 @@ my %titles = (
'Graffiti' => ['Graffiti', 'Graffiti', 'Offensive graffiti', 'Graffiti on the bridge', 'Remove graffiti'],
'Other' => ['Loose drain cover', 'Flytipping on country lane', 'Vehicle blocking footpath', 'Hedge encroaching pavement', 'Full litter bins'],
);
-my $postcode = mySociety::MaPit::call('area/example_postcode', $opt->area_id);
-$postcode = mySociety::MaPit::call('postcode', $postcode);
+
+my ($location, $lat, $lon);
+if ($opt->coords) {
+ $location = $opt->coords;
+ ($lat, $lon) = split ',', $location;
+} else {
+ my $postcode = mySociety::MaPit::call('area/example_postcode', $opt->area_id);
+ $postcode = mySociety::MaPit::call('postcode', $postcode);
+ ($location, $lat, $lon) = map { $postcode->{$_} } qw/postcode wgs84_lat wgs84_lon/;
+}
my $cobrand = 'default';
foreach (FixMyStreet::Cobrand->available_cobrand_classes) {
@@ -121,7 +130,7 @@ foreach (FixMyStreet::Cobrand->available_cobrand_classes) {
}
my $num = 10;
-say "Created $num problems around '$postcode->{postcode}' in cobrand '$cobrand'";
+say "Created $num problems around '$location' in cobrand '$cobrand'";
my $inaccurate_km = 0.01;
my $confirmed = DateTime->today->subtract(days => 1)->add(hours => 8);
my $problems = [];
@@ -133,9 +142,9 @@ for (1..$num) {
body => $body,
areas => ',' . $opt->area_id . ',',
user => $user,
- postcode => $postcode->{postcode},
- latitude => $postcode->{wgs84_lat} + rand($inaccurate_km) - $inaccurate_km / 2,
- longitude => $postcode->{wgs84_lon} + rand($inaccurate_km) - $inaccurate_km / 2,
+ postcode => $location,
+ latitude => $lat + rand($inaccurate_km) - $inaccurate_km / 2,
+ longitude => $lon + rand($inaccurate_km) - $inaccurate_km / 2,
category => $category,
cobrand => $cobrand,
title => $titles->[int(rand(@$titles))],