From 2e8df1a5a6610c43e0c1bda15d018fa16738061b Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Mon, 19 Jan 2015 16:20:55 +0000 Subject: Tidy up of bin directory. Remove some unneeded scripts, move others to cobrand-specific directories. --- .travis.yml | 2 +- bin/canonicalise-csv | 112 ------------ bin/canonicalise-eha | 80 --------- bin/comment-backfill | 21 --- bin/emptyhomes/canonicalise-eha | 80 +++++++++ bin/emptyhomes/make_welsh_po | 114 +++++++++++++ bin/export-norwegian-contacts | 97 ----------- bin/fiksgatami/export-norwegian-contacts | 97 +++++++++++ bin/fiksgatami/load-norwegian-contacts | 69 ++++++++ bin/fixmystreet.com/canonicalise-csv | 112 ++++++++++++ bin/fixmystreet.com/generate_council_location | 28 +++ bin/fixmystreet.com/import-categories | 78 +++++++++ bin/fixmystreet.com/load-contacts | 49 ++++++ bin/fixmystreet.com/populate_bing_cache | 60 +++++++ bin/fixmystreet.com/rotate-photos | 64 +++++++ bin/fixmystreet.com/showcouncilrates | 74 ++++++++ bin/fixmystreet.com/update-areas | 46 +++++ bin/fixmystreet.com/update-send-questionnaire | 29 ++++ bin/generate_council_location | 28 --- bin/import-categories | 78 --------- bin/install-as-user | 2 +- bin/kasabi | 234 -------------------------- bin/load-contacts | 49 ------ bin/load-norwegian-contacts | 69 -------- bin/make_emptyhomes_welsh_po | 114 ------------- bin/populate_bing_cache | 60 ------- bin/rotate-photos | 64 ------- bin/showcouncilrates | 74 -------- bin/update-areas | 46 ----- bin/update-send-questionnaire | 29 ---- bin/zerotb/import_clinic_list.pl | 115 +++++++++++++ bin/zerotb_import_clinic_list.pl | 115 ------------- bin/zurich-overdue-alert | 83 --------- bin/zurich/geocode | 45 ----- bin/zurich/overdue-alert | 83 +++++++++ data/kasabi-requirements.txt | 2 - perllib/FixMyStreet/DB/Result/Token.pm | 5 - perllib/Utils.pm | 1 - 38 files changed, 1100 insertions(+), 1408 deletions(-) delete mode 100755 bin/canonicalise-csv delete mode 100755 bin/canonicalise-eha delete mode 100755 bin/comment-backfill create mode 100755 bin/emptyhomes/canonicalise-eha create mode 100755 bin/emptyhomes/make_welsh_po delete mode 100644 bin/export-norwegian-contacts create mode 100644 bin/fiksgatami/export-norwegian-contacts create mode 100755 bin/fiksgatami/load-norwegian-contacts create mode 100755 bin/fixmystreet.com/canonicalise-csv create mode 100755 bin/fixmystreet.com/generate_council_location create mode 100755 bin/fixmystreet.com/import-categories create mode 100755 bin/fixmystreet.com/load-contacts create mode 100755 bin/fixmystreet.com/populate_bing_cache create mode 100755 bin/fixmystreet.com/rotate-photos create mode 100755 bin/fixmystreet.com/showcouncilrates create mode 100755 bin/fixmystreet.com/update-areas create mode 100755 bin/fixmystreet.com/update-send-questionnaire delete mode 100755 bin/generate_council_location delete mode 100755 bin/import-categories delete mode 100755 bin/kasabi delete mode 100755 bin/load-contacts delete mode 100755 bin/load-norwegian-contacts delete mode 100755 bin/make_emptyhomes_welsh_po delete mode 100755 bin/populate_bing_cache delete mode 100755 bin/rotate-photos delete mode 100755 bin/showcouncilrates delete mode 100755 bin/update-areas delete mode 100755 bin/update-send-questionnaire create mode 100755 bin/zerotb/import_clinic_list.pl delete mode 100755 bin/zerotb_import_clinic_list.pl delete mode 100755 bin/zurich-overdue-alert delete mode 100755 bin/zurich/geocode create mode 100755 bin/zurich/overdue-alert delete mode 100644 data/kasabi-requirements.txt diff --git a/.travis.yml b/.travis.yml index bad676933..1e4b7611f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,7 +33,7 @@ before_script: sed -r -e "s,(FMS_DB_USER:) 'fms',\\1 'postgres'," conf/general.yml-example > conf/general.yml - ./bin/cron-wrapper ./bin/make_po FixMyStreet-EmptyHomes - - ./bin/cron-wrapper ./bin/make_emptyhomes_welsh_po + - ./bin/cron-wrapper ./bin/emptyhomes/make_welsh_po - commonlib/bin/gettext-makemo FixMyStreet script: "bin/cron-wrapper perl /usr/bin/prove -rl t" after_script: diff --git a/bin/canonicalise-csv b/bin/canonicalise-csv deleted file mode 100755 index c0a7fc60b..000000000 --- a/bin/canonicalise-csv +++ /dev/null @@ -1,112 +0,0 @@ -#!/usr/bin/perl -w - -# canonicalise-csv: -# Convert provided CSV file into one with standard names for MaPit -# -# Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved. -# Email: matthew@mysociety.org. WWW: http://www.mysociety.org -# -# $Id: canonicalise-csv,v 1.4 2009-02-16 18:56:44 matthew Exp $ - -use strict; -require 5.8.0; - -# Horrible boilerplate to set up appropriate library paths. -use FindBin; -use lib "$FindBin::Bin/../perllib"; -use lib "$FindBin::Bin/../commonlib/perllib"; - -use mySociety::Config; -use mySociety::MaPit; -use mySociety::VotingArea; - -BEGIN { - mySociety::Config::set_file("$FindBin::Bin/../conf/general"); - mySociety::MaPit::configure(); -} - -my %councils; -open(FP, "$FindBin::Bin/../data/councils.csv") - or die "Can't read councils.csv: $!\n"; -while () { - s/\r?\n//g; - my ($name, $email) = split /,/; - $email ||= ''; - $email =~ s/\xa0//g; - - # Canonicalise - next if $name eq 'Londonderry'; # Dupe of Derry - next if $name eq 'Kingston upon Hull'; # Dupe of Hull - next if $name eq 'London' || $name eq 'Greater London'; # Untrustworthy - - # Different - $name = 'Corporation of London' if $name eq 'City of London'; - $name = "Renfrewsh'r" if $name eq 'Renfrewshire'; - # Shorter - $name = 'Blackburn' if $name eq 'Blackburn with Darwen'; - $name = 'Dungannon' if $name eq 'Dungannon & South Tyrone'; - $name = 'Staffordshire' if $name eq 'Staffordshire County'; - $name = 'Armagh' if $name eq 'Armagh City'; - # Longer - $name = 'Kingston upon Hull' if $name eq 'Hull'; - $name = "City of $name" if $name =~ /^(Edinburgh|Glasgow|York)$/; - $name .= ' Islands' if $name eq 'Shetland'; - $name .= ' & Chelsea' if $name eq 'Kensington'; - # Wrong - $name =~ s/King's Lynn/Kings Lynn/; - $name = 'Surrey Heath' if $name eq 'Surrey Health'; - $name = 'Barking & Dagenham' if $name eq 'Barking-Dagenham'; - $name = 'Newtownabbey' if $name eq 'Newtonabbey'; - $name = 'Isles of Scilly' if $name eq 'Isle of Scilly'; - # Compass - $name =~ s/North East /N. E. /; - $name =~ s/^North West /N. W. /; - $name =~ s/^North (?!Lincolnshire|Norfolk|Somerset)/N. /; - $name =~ s/^South (?!Shropshire|Staffordshire|Somerset)/S. /; - $name =~ s/^East (?!Staffordshire)/E. /; - $name =~ s/^West(ern)? (?!Berkshire|Wiltshire)/W. /; - $name =~ s/ W / W. /; - # Various - $name =~ s/^Great /Gt. /; - $name =~ s/^St /St. /; - $name =~ s/ and / & /; - $name =~ s/ ?Royal$//; - $name =~ s/ Borough$//; - $name =~ s/-(upon|on|le)-/ $1 /; - $councils{$name} = $email; -} -close(FP); - -my $types = $mySociety::VotingArea::council_parent_types; -my (%out, @missing); -foreach my $type (@$types) { - my $areas = mySociety::MaPit::get_areas_by_type($type); - my $areas_info = mySociety::MaPit::get_voting_areas_info($areas); - foreach my $id (keys %$areas_info) { - my $area_info = $areas_info->{$id}; - my $name = $area_info->{name}; - if ($name eq 'Durham City Council') { - $out{$id} = $councils{'Durham City'}; - next; - } elsif ($name eq 'Durham County Council') { - $out{$id} = $councils{'Durham County'}; - next; - } - $name =~ s/( (Borough|City|District|County))* Council//; - if ($councils{$name} && $councils{$name} =~ /@/) { - $out{$id} = $councils{$name}; - } elsif ($councils{$name} || exists($councils{$name})) { - push @missing, $id; - } - } -} - -# Output missing IDs to STDOUT -print join(',', @missing) . "\n"; - -# Output emails to canonical CSV -open(FP, ">$FindBin::Bin/../data/councils_canonical.csv"); -foreach (sort keys %out) { - print FP "$_," . $out{$_} . "\n"; -} -close FP; diff --git a/bin/canonicalise-eha b/bin/canonicalise-eha deleted file mode 100755 index 1030982fa..000000000 --- a/bin/canonicalise-eha +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/perl -w - -# canonicalise-eha: -# Convert provided TSV file into one with standard names for MaPit -# -# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. -# Email: matthew@mysociety.org. WWW: http://www.mysociety.org -# -# $Id: canonicalise-eha,v 1.1 2009-05-27 11:11:18 matthew Exp $ - -use strict; -require 5.8.0; - -# Horrible boilerplate to set up appropriate library paths. -use FindBin; -use lib "$FindBin::Bin/../perllib"; -use lib "$FindBin::Bin/../commonlib/perllib"; - -use mySociety::Config; -use mySociety::MaPit; -use mySociety::VotingArea; - -BEGIN { - mySociety::Config::set_file("$FindBin::Bin/../conf/general"); - mySociety::MaPit::configure(); -} - -my %councils; -open(FP, "$FindBin::Bin/../data/eha_listN"); -while () { - s/\r?\n//g; - my ($name, $email) = split /\s*\t+\s*/; - $email ||= ''; - #$name = 'Blackburn' if $name eq 'Blackburn with Darwen'; - $name =~ s/^St /St. /; - $name =~ s/-(upon|on|le)-/ $1 /; - $name =~ s/^LB //; - $name =~ s/ BC| DC| MDC| MBC| (Metropolitan|Borough|District|County|City) Council| Council//; - print "Already have $name\n" if $councils{$name}; - $councils{$name} = $email; -} -close(FP); - -my @types = grep { $_ !~ /CTY|LGD/ } @$mySociety::VotingArea::council_parent_types; -my (%out); -foreach my $type (@types) { - my $areas = mySociety::MaPit::get_areas_by_type($type); - my $areas_info = mySociety::MaPit::get_voting_areas_info($areas); - foreach my $id (keys %$areas_info) { - my $area_info = $areas_info->{$id}; - next if $area_info->{country} eq 'S'; - my $name = $area_info->{name}; - if ($name eq 'Durham City Council') { - $out{$id} = $councils{'Durham City'}; - delete $councils{'Durham City'}; - next; - #} elsif ($name eq 'Durham County Council') { - # $out{$id} = $councils{'Durham County'}; - # next; - } - $name =~ s/( (Borough|City|District|County))* Council//; - if ($councils{$name} && $councils{$name} =~ /@/) { - $out{$id} = $councils{$name}; - delete $councils{$name}; - } else { - print "Problem: $name $area_info->{country}\n"; - } - } -} - -foreach (sort keys %councils) { - print "Not matched: $_ $councils{$_}\n"; -} - -# Output emails to canonical CSV -open(FP, ">$FindBin::Bin/../data/eha.csv"); -foreach (sort keys %out) { - print FP "$_," . $out{$_} . "\n"; -} -close FP; diff --git a/bin/comment-backfill b/bin/comment-backfill deleted file mode 100755 index e296d7756..000000000 --- a/bin/comment-backfill +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env perl - -use strict; -use warnings; -require 5.8.0; -use DateTime; - -use FixMyStreet::App; - -use Open311; -use Open311::GetServiceRequestUpdates; - -my $start_time = DateTime->now->subtract( days => 1, hours => 1 ); -my $end_time = DateTime->now; - -my $updates = Open311::GetServiceRequestUpdates->new( - start_date => $start_time, - end_date => $end_time, -); - -$updates->fetch; diff --git a/bin/emptyhomes/canonicalise-eha b/bin/emptyhomes/canonicalise-eha new file mode 100755 index 000000000..1030982fa --- /dev/null +++ b/bin/emptyhomes/canonicalise-eha @@ -0,0 +1,80 @@ +#!/usr/bin/perl -w + +# canonicalise-eha: +# Convert provided TSV file into one with standard names for MaPit +# +# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. +# Email: matthew@mysociety.org. WWW: http://www.mysociety.org +# +# $Id: canonicalise-eha,v 1.1 2009-05-27 11:11:18 matthew Exp $ + +use strict; +require 5.8.0; + +# Horrible boilerplate to set up appropriate library paths. +use FindBin; +use lib "$FindBin::Bin/../perllib"; +use lib "$FindBin::Bin/../commonlib/perllib"; + +use mySociety::Config; +use mySociety::MaPit; +use mySociety::VotingArea; + +BEGIN { + mySociety::Config::set_file("$FindBin::Bin/../conf/general"); + mySociety::MaPit::configure(); +} + +my %councils; +open(FP, "$FindBin::Bin/../data/eha_listN"); +while () { + s/\r?\n//g; + my ($name, $email) = split /\s*\t+\s*/; + $email ||= ''; + #$name = 'Blackburn' if $name eq 'Blackburn with Darwen'; + $name =~ s/^St /St. /; + $name =~ s/-(upon|on|le)-/ $1 /; + $name =~ s/^LB //; + $name =~ s/ BC| DC| MDC| MBC| (Metropolitan|Borough|District|County|City) Council| Council//; + print "Already have $name\n" if $councils{$name}; + $councils{$name} = $email; +} +close(FP); + +my @types = grep { $_ !~ /CTY|LGD/ } @$mySociety::VotingArea::council_parent_types; +my (%out); +foreach my $type (@types) { + my $areas = mySociety::MaPit::get_areas_by_type($type); + my $areas_info = mySociety::MaPit::get_voting_areas_info($areas); + foreach my $id (keys %$areas_info) { + my $area_info = $areas_info->{$id}; + next if $area_info->{country} eq 'S'; + my $name = $area_info->{name}; + if ($name eq 'Durham City Council') { + $out{$id} = $councils{'Durham City'}; + delete $councils{'Durham City'}; + next; + #} elsif ($name eq 'Durham County Council') { + # $out{$id} = $councils{'Durham County'}; + # next; + } + $name =~ s/( (Borough|City|District|County))* Council//; + if ($councils{$name} && $councils{$name} =~ /@/) { + $out{$id} = $councils{$name}; + delete $councils{$name}; + } else { + print "Problem: $name $area_info->{country}\n"; + } + } +} + +foreach (sort keys %councils) { + print "Not matched: $_ $councils{$_}\n"; +} + +# Output emails to canonical CSV +open(FP, ">$FindBin::Bin/../data/eha.csv"); +foreach (sort keys %out) { + print FP "$_," . $out{$_} . "\n"; +} +close FP; diff --git a/bin/emptyhomes/make_welsh_po b/bin/emptyhomes/make_welsh_po new file mode 100755 index 000000000..a85e7c35b --- /dev/null +++ b/bin/emptyhomes/make_welsh_po @@ -0,0 +1,114 @@ +#!/usr/bin/perl -w +use strict; + +# Given a translation of the Empty Homes version of the FixMyStreet .po file, +# fix it all up to go direct from FixMyStreet -> EH translation. + +use POSIX; +use FindBin; +use lib "$FindBin::Bin/../../perllib"; +use PoChange; + +chdir("$FindBin::Bin/../../locale"); + +# First read in translation and match up. +open(INPO, 'cy_GB.UTF-8/LC_MESSAGES/EmptyHomes.po') or die $!; + +my $state = 'start'; +my $msgid = ''; +my $fuzzy = 0; +my $msgstr; +my %lookup; +while () { + if (m/^#, fuzzy/) { + $fuzzy = 1; + } elsif (m/^#/) { + # comment or blank line + } elsif (m/^\s+$/) { + # blank line separates translations + $msgid =~ s/"\n"//g; + $lookup{$msgid} = [ $msgstr, $fuzzy ]; + $state = 'msgid'; + $msgid = ""; + $fuzzy = 0; + } elsif ($state eq 'msgid' && (m/^msgstr "/ || m/^msgstr\[0\] "/)) { + $msgstr = $_; + $state = 'msgstr'; + } elsif ($state eq 'msgstr') { + $msgstr .= $_; + } elsif ($state eq 'msgid') { + $msgid .= $_; + } +} +$lookup{$msgid} = [ $msgstr, $fuzzy ]; +close INPO; + +mkdir("en_GB.UTF-8"); +mkdir("en_GB.UTF-8/LC_MESSAGES"); +mkdir("cy_GB.UTF-8"); +mkdir("cy_GB.UTF-8/LC_MESSAGES"); + +open(MAINPO, 'FixMyStreet.po') or die; +open(OUTPO, ">cy_GB.UTF-8/LC_MESSAGES/FixMyStreet-EmptyHomes.po") or die; + +print OUTPO "# AUTOMATICALLY GENERATED by make_welsh_po, do not edit\n\n"; + +my $buffer = ""; +my $start = 0; +while() { + if (!$start) { + s/#, fuzzy/#/; + } + if (m/"Last-Translator: FULL NAME/) { + $_ = '"Last-Translator: mysociety/bin/emptyhomes/make_welsh_po\\n"'."\n"; + } + if (m/"PO-Revision-Date: YEAR-MO-DA/) { + my $time = POSIX::strftime("%Y-%m-%d %H:%M%z", localtime(time())); + $_ = '"PO-Revision-Date: '.$time.'\\n"'."\n"; + } + if (m/"Language-Team: LANGUAGE/) { + $_ = '"Language-Team: mySociety\\n"'."\n"; + } + if (m/"Plural-Forms: nplurals=/) { + $_ = '"Plural-Forms: nplurals=2; plural=n != 1;\\n"'."\n"; + } + + if (m/^#/) { + # comment or blank line + print OUTPO $_; + } elsif (m/^\s+$/) { + # blank line + $start = 1; + $buffer = ""; + print OUTPO $_; + } elsif ($start && (m/^msgstr "/ || m/^msgstr\[0\] "/)) { + # start of translated text - translate English into Empty Homes language + my $new_buffer = PoChange::fixmystreet_to_reportemptyhomes($buffer); + $new_buffer =~ s/"\n"//g; + + if ($lookup{$new_buffer} && $lookup{$new_buffer}[1]) { + print OUTPO "#, fuzzy\n"; + } + + print OUTPO $buffer; + if ($lookup{$new_buffer}) { + print OUTPO $lookup{$new_buffer}[0]; + } else { + if (m/^msgstr\[0\] ""/) { + $new_buffer =~ s/^msgid "/msgstr[0] "/m; + $new_buffer =~ s/^msgid_plural "/msgstr[1] "/m; + $_ = ; # skip untranslated plural + } else { + $new_buffer =~ s/^msgid "/msgstr "/; + } + print OUTPO $new_buffer; + } + + $buffer = ""; + } elsif (!$start) { + print OUTPO $_; + } else { + $buffer .= $_; + } +} + diff --git a/bin/export-norwegian-contacts b/bin/export-norwegian-contacts deleted file mode 100644 index 0209c6512..000000000 --- a/bin/export-norwegian-contacts +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/perl - -# export-norwegian-contacts: -# Export initial contact list from fiksgatami in a format usable by -# load-norwegian-contact. -# -# The format is -# ID;Name;email-address;Category1,Category2,... -# -# Based on script load-contacts copyright (c) 2006 UK Citizens Online -# Democracy and script load-norwegian-contacts copyright (c) 2011 -# Petter Reinholdtsen. -# Copyright 2011 Petter Reinholdtsen. -# -# $Id: load-norwegian-contacts,v 1.0 2007-08-02 11:44:59 matthew Exp $ - -use strict; -use warnings; -require 5.8.0; -use open OUT => ':utf8'; - -# Horrible boilerplate to set up appropriate library paths. -use FindBin; -use lib "$FindBin::Bin/../perllib"; -use lib "$FindBin::Bin/../commonlib/perllib"; - -use mySociety::Config; -use mySociety::DBHandle qw(dbh select_all); -use mySociety::MaPit; - -BEGIN { - mySociety::Config::set_file("$FindBin::Bin/../conf/general"); - mySociety::DBHandle::configure( - Name => mySociety::Config::get('FMS_DB_NAME'), - User => mySociety::Config::get('FMS_DB_USER'), - Password => mySociety::Config::get('FMS_DB_PASS'), - Host => mySociety::Config::get('FMS_DB_HOST', undef), - Port => mySociety::Config::get('FMS_DB_PORT', undef) - ); -} - -my $datafile = shift; - -open(my $fh, '>', $datafile) or die "Unable to write to $datafile"; - -# Categories used by more than half the areas is used as the default -# list. -my $sql = - "SELECT category FROM (SELECT category, COUNT(*) from contacts ". - " WHERE confirmed = 'true' AND deleted = 'false' ". - " GROUP BY category) as c ". - " WHERE count > (SELECT COUNT(*)/2 FROM contacts ". - " WHERE category = 'Annet') ". - " ORDER BY category"; -my $defcategoriesref = dbh()->selectcol_arrayref($sql); -print $fh "0000;default;;", join(',', @{$defcategoriesref}), "\n"; - -my %categorygroup; -$sql = "SELECT area_id, email, category FROM contacts ORDER BY category"; -my $contactref = dbh()->selectall_arrayref($sql, { Slice => {} }); -my @area_ids; -for my $row (@{$contactref}) { - my $key = $row->{area_id} .':'. $row->{email}; - push(@area_ids, $row->{area_id}); - if (exists $categorygroup{$key}) { - push(@{$categorygroup{$key}}, $row->{category}); - } else { - $categorygroup{$key} = [ $row->{category} ]; - } -} - -my $areas_info = mySociety::MaPit::call('areas', \@area_ids); - -my @list; -for my $key (keys %categorygroup) { - my ($area_id, $email) = split(/:/, $key); - my $categoriesref = $categorygroup{$key}; - my $areaname = $areas_info->{$area_id}->{name}; - my $areadigits = ($area_id < 100) ? 2 : 4; - if (identical_lists($defcategoriesref, $categoriesref)) { - push(@list,sprintf("%0${areadigits}d;%s;%s\n", - $area_id, $areaname, $email)); - } else { - push(@list, sprintf("%0${areadigits}d;%s;%s;%s\n", - $area_id, $areaname, $email, - join(',', @{$categoriesref}))); - } -} - -print $fh sort @list; - -sub identical_lists { - my ($a, $b) = @_; - return !(join(',', @{$a}) cmp join(',', @{$b})); -} - -exit 0; diff --git a/bin/fiksgatami/export-norwegian-contacts b/bin/fiksgatami/export-norwegian-contacts new file mode 100644 index 000000000..0209c6512 --- /dev/null +++ b/bin/fiksgatami/export-norwegian-contacts @@ -0,0 +1,97 @@ +#!/usr/bin/perl + +# export-norwegian-contacts: +# Export initial contact list from fiksgatami in a format usable by +# load-norwegian-contact. +# +# The format is +# ID;Name;email-address;Category1,Category2,... +# +# Based on script load-contacts copyright (c) 2006 UK Citizens Online +# Democracy and script load-norwegian-contacts copyright (c) 2011 +# Petter Reinholdtsen. +# Copyright 2011 Petter Reinholdtsen. +# +# $Id: load-norwegian-contacts,v 1.0 2007-08-02 11:44:59 matthew Exp $ + +use strict; +use warnings; +require 5.8.0; +use open OUT => ':utf8'; + +# Horrible boilerplate to set up appropriate library paths. +use FindBin; +use lib "$FindBin::Bin/../perllib"; +use lib "$FindBin::Bin/../commonlib/perllib"; + +use mySociety::Config; +use mySociety::DBHandle qw(dbh select_all); +use mySociety::MaPit; + +BEGIN { + mySociety::Config::set_file("$FindBin::Bin/../conf/general"); + mySociety::DBHandle::configure( + Name => mySociety::Config::get('FMS_DB_NAME'), + User => mySociety::Config::get('FMS_DB_USER'), + Password => mySociety::Config::get('FMS_DB_PASS'), + Host => mySociety::Config::get('FMS_DB_HOST', undef), + Port => mySociety::Config::get('FMS_DB_PORT', undef) + ); +} + +my $datafile = shift; + +open(my $fh, '>', $datafile) or die "Unable to write to $datafile"; + +# Categories used by more than half the areas is used as the default +# list. +my $sql = + "SELECT category FROM (SELECT category, COUNT(*) from contacts ". + " WHERE confirmed = 'true' AND deleted = 'false' ". + " GROUP BY category) as c ". + " WHERE count > (SELECT COUNT(*)/2 FROM contacts ". + " WHERE category = 'Annet') ". + " ORDER BY category"; +my $defcategoriesref = dbh()->selectcol_arrayref($sql); +print $fh "0000;default;;", join(',', @{$defcategoriesref}), "\n"; + +my %categorygroup; +$sql = "SELECT area_id, email, category FROM contacts ORDER BY category"; +my $contactref = dbh()->selectall_arrayref($sql, { Slice => {} }); +my @area_ids; +for my $row (@{$contactref}) { + my $key = $row->{area_id} .':'. $row->{email}; + push(@area_ids, $row->{area_id}); + if (exists $categorygroup{$key}) { + push(@{$categorygroup{$key}}, $row->{category}); + } else { + $categorygroup{$key} = [ $row->{category} ]; + } +} + +my $areas_info = mySociety::MaPit::call('areas', \@area_ids); + +my @list; +for my $key (keys %categorygroup) { + my ($area_id, $email) = split(/:/, $key); + my $categoriesref = $categorygroup{$key}; + my $areaname = $areas_info->{$area_id}->{name}; + my $areadigits = ($area_id < 100) ? 2 : 4; + if (identical_lists($defcategoriesref, $categoriesref)) { + push(@list,sprintf("%0${areadigits}d;%s;%s\n", + $area_id, $areaname, $email)); + } else { + push(@list, sprintf("%0${areadigits}d;%s;%s;%s\n", + $area_id, $areaname, $email, + join(',', @{$categoriesref}))); + } +} + +print $fh sort @list; + +sub identical_lists { + my ($a, $b) = @_; + return !(join(',', @{$a}) cmp join(',', @{$b})); +} + +exit 0; diff --git a/bin/fiksgatami/load-norwegian-contacts b/bin/fiksgatami/load-norwegian-contacts new file mode 100755 index 000000000..b73778848 --- /dev/null +++ b/bin/fiksgatami/load-norwegian-contacts @@ -0,0 +1,69 @@ +#!/usr/bin/perl -w + +# load-norwegian-contacts: +# Load initial contact list into fiksgatami. +# The format is +# Name;ID;email-address;Category1,Category2,... +# +# Based on script load-contacts copyright (c) 2006 UK Citizens Online Democracy. +# Copyright 2011 Petter Reinholdtsen +# +# $Id: load-norwegian-contacts,v 1.0 2007-08-02 11:44:59 matthew Exp $ + +use strict; +require 5.8.0; + +# Horrible boilerplate to set up appropriate library paths. +use FindBin; +use lib "$FindBin::Bin/../perllib"; +use lib "$FindBin::Bin/../commonlib/perllib"; + +use mySociety::Config; +use mySociety::DBHandle qw(dbh select_all); +use mySociety::Random; + +BEGIN { + mySociety::Config::set_file("$FindBin::Bin/../conf/general"); + mySociety::DBHandle::configure( + Name => mySociety::Config::get('FMS_DB_NAME'), + User => mySociety::Config::get('FMS_DB_USER'), + Password => mySociety::Config::get('FMS_DB_PASS'), + Host => mySociety::Config::get('FMS_DB_HOST', undef), + Port => mySociety::Config::get('FMS_DB_PORT', undef) + ); + + if (!dbh()->selectrow_array('select secret from secret for update of secret')) { + local dbh()->{HandleError}; + dbh()->do('insert into secret (secret) values (?)', {}, unpack('h*', mySociety::Random::random_bytes(32))); + } + dbh()->commit(); +} + +my $datafile = shift; +my $defcategories; +open(FP, "<", $datafile) or die "Unable to read from $datafile"; +while () { + s/\r?\n//g; + print "Loading $_\n"; + my ($id, $name, $email, $categories) = split /;/; + if (0 == $id) { + $defcategories = $categories; + next; + } + unless ($categories) { + $categories = $defcategories; + } +# dbh()->do("INSERT INTO contacts (area_id, email, editor, whenedited, note, confirmed, deleted) +# VALUES (?, ?, 'import', ms_current_timestamp(), 'Initial import', 'false', 'false')", +# {}, $id, $email); +# } else { + for my $category (split(/,\s*/, $categories)) { + print " Category '$category'\n"; + dbh()->do("INSERT INTO contacts (area_id, email, category, editor, whenedited, note, confirmed, deleted) + VALUES (?, ?, ?, 'import', ms_current_timestamp(), 'Initial import', 'true', 'false')", + {}, $id, $email, $category); + } +# } +} +dbh()->commit(); +close(FP); diff --git a/bin/fixmystreet.com/canonicalise-csv b/bin/fixmystreet.com/canonicalise-csv new file mode 100755 index 000000000..c0a7fc60b --- /dev/null +++ b/bin/fixmystreet.com/canonicalise-csv @@ -0,0 +1,112 @@ +#!/usr/bin/perl -w + +# canonicalise-csv: +# Convert provided CSV file into one with standard names for MaPit +# +# Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved. +# Email: matthew@mysociety.org. WWW: http://www.mysociety.org +# +# $Id: canonicalise-csv,v 1.4 2009-02-16 18:56:44 matthew Exp $ + +use strict; +require 5.8.0; + +# Horrible boilerplate to set up appropriate library paths. +use FindBin; +use lib "$FindBin::Bin/../perllib"; +use lib "$FindBin::Bin/../commonlib/perllib"; + +use mySociety::Config; +use mySociety::MaPit; +use mySociety::VotingArea; + +BEGIN { + mySociety::Config::set_file("$FindBin::Bin/../conf/general"); + mySociety::MaPit::configure(); +} + +my %councils; +open(FP, "$FindBin::Bin/../data/councils.csv") + or die "Can't read councils.csv: $!\n"; +while () { + s/\r?\n//g; + my ($name, $email) = split /,/; + $email ||= ''; + $email =~ s/\xa0//g; + + # Canonicalise + next if $name eq 'Londonderry'; # Dupe of Derry + next if $name eq 'Kingston upon Hull'; # Dupe of Hull + next if $name eq 'London' || $name eq 'Greater London'; # Untrustworthy + + # Different + $name = 'Corporation of London' if $name eq 'City of London'; + $name = "Renfrewsh'r" if $name eq 'Renfrewshire'; + # Shorter + $name = 'Blackburn' if $name eq 'Blackburn with Darwen'; + $name = 'Dungannon' if $name eq 'Dungannon & South Tyrone'; + $name = 'Staffordshire' if $name eq 'Staffordshire County'; + $name = 'Armagh' if $name eq 'Armagh City'; + # Longer + $name = 'Kingston upon Hull' if $name eq 'Hull'; + $name = "City of $name" if $name =~ /^(Edinburgh|Glasgow|York)$/; + $name .= ' Islands' if $name eq 'Shetland'; + $name .= ' & Chelsea' if $name eq 'Kensington'; + # Wrong + $name =~ s/King's Lynn/Kings Lynn/; + $name = 'Surrey Heath' if $name eq 'Surrey Health'; + $name = 'Barking & Dagenham' if $name eq 'Barking-Dagenham'; + $name = 'Newtownabbey' if $name eq 'Newtonabbey'; + $name = 'Isles of Scilly' if $name eq 'Isle of Scilly'; + # Compass + $name =~ s/North East /N. E. /; + $name =~ s/^North West /N. W. /; + $name =~ s/^North (?!Lincolnshire|Norfolk|Somerset)/N. /; + $name =~ s/^South (?!Shropshire|Staffordshire|Somerset)/S. /; + $name =~ s/^East (?!Staffordshire)/E. /; + $name =~ s/^West(ern)? (?!Berkshire|Wiltshire)/W. /; + $name =~ s/ W / W. /; + # Various + $name =~ s/^Great /Gt. /; + $name =~ s/^St /St. /; + $name =~ s/ and / & /; + $name =~ s/ ?Royal$//; + $name =~ s/ Borough$//; + $name =~ s/-(upon|on|le)-/ $1 /; + $councils{$name} = $email; +} +close(FP); + +my $types = $mySociety::VotingArea::council_parent_types; +my (%out, @missing); +foreach my $type (@$types) { + my $areas = mySociety::MaPit::get_areas_by_type($type); + my $areas_info = mySociety::MaPit::get_voting_areas_info($areas); + foreach my $id (keys %$areas_info) { + my $area_info = $areas_info->{$id}; + my $name = $area_info->{name}; + if ($name eq 'Durham City Council') { + $out{$id} = $councils{'Durham City'}; + next; + } elsif ($name eq 'Durham County Council') { + $out{$id} = $councils{'Durham County'}; + next; + } + $name =~ s/( (Borough|City|District|County))* Council//; + if ($councils{$name} && $councils{$name} =~ /@/) { + $out{$id} = $councils{$name}; + } elsif ($councils{$name} || exists($councils{$name})) { + push @missing, $id; + } + } +} + +# Output missing IDs to STDOUT +print join(',', @missing) . "\n"; + +# Output emails to canonical CSV +open(FP, ">$FindBin::Bin/../data/councils_canonical.csv"); +foreach (sort keys %out) { + print FP "$_," . $out{$_} . "\n"; +} +close FP; diff --git a/bin/fixmystreet.com/generate_council_location b/bin/fixmystreet.com/generate_council_location new file mode 100755 index 000000000..c7aea8074 --- /dev/null +++ b/bin/fixmystreet.com/generate_council_location @@ -0,0 +1,28 @@ +#!/usr/bin/perl + +use strict; +use JSON; +use LWP::Simple; + +my $id = shift; + +my $url = sprintf( 'http://mapit.mysociety.org/area/%s/geometry', $id); + +my $json = get( $url ); +my $geo = decode_json( $json ); + +my $max_lat = $geo->{max_lat}; +my $min_lat = $geo->{min_lat}; +my $max_lon = $geo->{max_lon}; +my $min_lon = $geo->{min_lon}; +my $c_lat = $geo->{centre_lat}; +my $c_lon = $geo->{centre_lon}; + +my $spn_lat = $max_lat - $min_lat; +my $spn_lon = $max_lon - $min_lon; + +print <<"EOT"; + centre => '$c_lat,$c_lon', + span => '$spn_lat,$spn_lon', + bounds => [ $min_lat, $min_lon, $max_lat, $max_lon ], +EOT diff --git a/bin/fixmystreet.com/import-categories b/bin/fixmystreet.com/import-categories new file mode 100755 index 000000000..e9008b93f --- /dev/null +++ b/bin/fixmystreet.com/import-categories @@ -0,0 +1,78 @@ +#!/usr/bin/perl -w + +# import-categories: +# Initial choice of categories for councils. Most likely wrong. +# +# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. +# Email: matthew@mysociety.org. WWW: http://www.mysociety.org +# +# $Id: import-categories,v 1.3 2007-08-02 11:44:59 matthew Exp $ + +use strict; +require 5.8.0; + +# Horrible boilerplate to set up appropriate library paths. +use FindBin; +use lib "$FindBin::Bin/../perllib"; +use lib "$FindBin::Bin/../commonlib/perllib"; + +use mySociety::Config; +use mySociety::DBHandle qw(dbh select_all); +use mySociety::MaPit; +use mySociety::VotingArea; + +BEGIN { + mySociety::Config::set_file("$FindBin::Bin/../conf/general"); + mySociety::DBHandle::configure( + Name => mySociety::Config::get('FMS_DB_NAME'), + User => mySociety::Config::get('FMS_DB_USER'), + Password => mySociety::Config::get('FMS_DB_PASS'), + Host => mySociety::Config::get('FMS_DB_HOST', undef), + Port => mySociety::Config::get('FMS_DB_PORT', undef) + ); +} + +my @district_cats = ( + 'Abandoned vehicles', 'Car parking', 'Dog fouling', 'Flyposting', 'Flytipping', + 'Graffiti', 'Parks/landscapes', 'Public toilets', 'Rubbish (refuse and recycling)', + 'Street nameplates', 'Street cleaning', 'Trees' +); +my @county_cats = ( + 'Bus stops', 'Pavements/footpaths', 'Potholes', 'Roads/highways', + 'Road traffic signs', 'Street lighting', 'Traffic lights' +); + +my @councils; +foreach my $type (@$mySociety::VotingArea::council_parent_types) { + my $areas = mySociety::MaPit::get_areas_by_type($type); + push @councils, @$areas; +} +my $councils = mySociety::MaPit::get_voting_areas_info(\@councils); +foreach my $id (keys %$councils) { + my $type = $councils->{$id}->{type}; + my ($email,$confirmed) = dbh()->selectrow_array( + "SELECT email,confirmed FROM contacts WHERE deleted='f' + and area_id=? AND category='Other'", {}, $id); + next unless $email; + if ($type eq 'DIS') { + add_categories($id, $email, $confirmed, @district_cats); + } elsif ($type eq 'CTY') { + add_categories($id, $email, $confirmed, @county_cats); + } else { + add_categories($id, $email, $confirmed, @district_cats, @county_cats); + } +} +dbh()->commit(); + +sub add_categories { + my ($id, $email, $confirmed, @cats) = @_; + foreach (@cats) { + dbh()->do("insert into contacts + (area_id, category, email, editor, whenedited, note, confirmed, deleted) + values + (?, ?, ?, 'import', ms_current_timestamp(), 'Initial copy', ?, 'f')", {}, + $id, $_, $email, ($confirmed ? 1 : 0) + ); + } +} + diff --git a/bin/fixmystreet.com/load-contacts b/bin/fixmystreet.com/load-contacts new file mode 100755 index 000000000..b18699db1 --- /dev/null +++ b/bin/fixmystreet.com/load-contacts @@ -0,0 +1,49 @@ +#!/usr/bin/perl -w + +# canonicalise-csv: +# Convert provided CSV file into one with standard names for MaPit +# +# Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved. +# Email: matthew@mysociety.org. WWW: http://www.mysociety.org +# +# $Id: load-contacts,v 1.3 2007-08-02 11:44:59 matthew Exp $ + +use strict; +require 5.8.0; + +# Horrible boilerplate to set up appropriate library paths. +use FindBin; +use lib "$FindBin::Bin/../perllib"; +use lib "$FindBin::Bin/../commonlib/perllib"; + +use mySociety::Config; +use mySociety::DBHandle qw(dbh select_all); +use mySociety::Random; + +BEGIN { + mySociety::Config::set_file("$FindBin::Bin/../conf/general"); + mySociety::DBHandle::configure( + Name => mySociety::Config::get('FMS_DB_NAME'), + User => mySociety::Config::get('FMS_DB_USER'), + Password => mySociety::Config::get('FMS_DB_PASS'), + Host => mySociety::Config::get('FMS_DB_HOST', undef), + Port => mySociety::Config::get('FMS_DB_PORT', undef) + ); + + if (!dbh()->selectrow_array('select secret from secret for update of secret')) { + local dbh()->{HandleError}; + dbh()->do('insert into secret (secret) values (?)', {}, unpack('h*', mySociety::Random::random_bytes(32))); + } + dbh()->commit(); +} + +open(FP, "$FindBin::Bin/../data/councils_canonical.csv"); +while () { + s/\r?\n//g; + my ($id, $email) = split /,/; + dbh()->do("INSERT INTO contacts (area_id, email, editor, whenedited, note) + VALUES (?, ?, 'import', ms_current_timestamp(), 'Initial import')", + {}, $id, $email); +} +dbh()->commit(); +close(FP); diff --git a/bin/fixmystreet.com/populate_bing_cache b/bin/fixmystreet.com/populate_bing_cache new file mode 100755 index 000000000..17c8911d0 --- /dev/null +++ b/bin/fixmystreet.com/populate_bing_cache @@ -0,0 +1,60 @@ +#!/usr/bin/perl + +use strict; +use warnings; +require 5.8.0; + +use Data::Dumper; + +use FixMyStreet::App; +use FixMyStreet::Geocode::Bing; + +my $bing_culture = 'en-GB'; + +my $reports = FixMyStreet::App->model('DB::Problem')->search( + { + geocode => undef, + confirmed => { '!=', undef }, + latitude => { '!=', 0 }, + longitude => { '!=', 0 }, + }, + { + select => [qw/id geocode confirmed latitude longitude/], + order_by => { -desc => 'confirmed' } + } +); + +my $num_reports = $reports->count(); +print "Found $num_reports lacking geocode information\n"; + +my $time_to_do = ( $num_reports * 10 ) / 60 / 60; +if ( $time_to_do > 24 ) { + my $days = $time_to_do / 24; + my $hours = $time_to_do % 24; + printf( "Should take %d days and %d hours to finish\n", $days, $hours ); +} +elsif ( $time_to_do < 1 ) { + printf( "Should take %d minutes to finish\n", $time_to_do * 60 ); +} +else { + my $mins = ( $num_reports * 10 ) / 60 % 60; + printf( "Should take %d hours and %d minutes to finish\n", + $time_to_do, $mins ); +} + +while ( my $report = $reports->next ) { + $num_reports--; + next unless $report->latitude && $report->longitude; + next if $report->geocode; + + my $j = FixMyStreet::Geocode::Bing::reverse( $report->latitude, + $report->longitude, $bing_culture ); + + $report->geocode($j); + $report->update; + + print "$num_reports left to populate\n" unless $num_reports % 100; + sleep 10; +} + +print "done\n"; diff --git a/bin/fixmystreet.com/rotate-photos b/bin/fixmystreet.com/rotate-photos new file mode 100755 index 000000000..7b8109d65 --- /dev/null +++ b/bin/fixmystreet.com/rotate-photos @@ -0,0 +1,64 @@ +#!/usr/bin/perl -w + +# rotate-photos: +# Manaully fix any already-uploaded photos that are orientated wrongly. +# +# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. +# Email: matthew@mysociety.org. WWW: http://www.mysociety.org +# +# $Id: rotate-photos,v 1.1 2008-12-11 15:18:40 matthew Exp $ + +use strict; +require 5.8.0; + +# Horrible boilerplate to set up appropriate library paths. +use FindBin; +use lib "$FindBin::Bin/../perllib"; +use lib "$FindBin::Bin/../commonlib/perllib"; + +use Digest::SHA qw(sha1_hex); + +use Utils; +use mySociety::Config; +use mySociety::DBHandle qw(dbh select_all); +use mySociety::TempFiles; + +BEGIN { + mySociety::Config::set_file("$FindBin::Bin/../conf/general"); + mySociety::DBHandle::configure( + Name => mySociety::Config::get('FMS_DB_NAME'), + User => mySociety::Config::get('FMS_DB_USER'), + Password => mySociety::Config::get('FMS_DB_PASS'), + Host => mySociety::Config::get('FMS_DB_HOST', undef), + Port => mySociety::Config::get('FMS_DB_PORT', undef) + ); +} + +my $r = select_all("select id, photo from problem where service='iPhone'"); +foreach (@$r) { + my $id = $_->{id}; + my $photo = $_->{photo}; + + if (length($photo) == 40) { + # If photo field contains a hash + my $filename = mySociety::Config::get('UPLOAD_DIR') . "$photo.jpeg"; + `jhead -autorot $filename`; + } else { + my ($fh, $filename) = mySociety::TempFiles::named_tempfile('.jpeg'); + print $fh $photo; + close $fh; + my $out = `jhead -autorot $filename`; + if ($out) { + open(FP, $filename) or die $!; + $photo = join('', ); + close FP; + my $fileid = sha1_hex($photo); + rename $filename, mySociety::Config::get('UPLOAD_DIR') . "$fileid.jpeg"; + dbh()->do('UPDATE problem SET photo=? WHERE id=?', {}, $fileid, $id); + dbh()->commit(); + } else { + unlink $filename; + } + } +} + diff --git a/bin/fixmystreet.com/showcouncilrates b/bin/fixmystreet.com/showcouncilrates new file mode 100755 index 000000000..1dacae597 --- /dev/null +++ b/bin/fixmystreet.com/showcouncilrates @@ -0,0 +1,74 @@ +#!/usr/bin/perl + +use warnings; +use strict; + +use FindBin; +use lib "$FindBin::Bin/../perllib"; +use lib "$FindBin::Bin/../commonlib/perllib"; + +use POSIX qw(strcoll); +use mySociety::DBHandle qw(dbh); + +use mySociety::MaPit; +use FixMyStreet::Geocode::OSM; + +BEGIN { + mySociety::Config::set_file("$FindBin::Bin/../conf/general"); + mySociety::DBHandle::configure( + Name => mySociety::Config::get('FMS_DB_NAME'), + User => mySociety::Config::get('FMS_DB_USER'), + Password => mySociety::Config::get('FMS_DB_PASS'), + Host => mySociety::Config::get('FMS_DB_HOST', undef), + Port => mySociety::Config::get('FMS_DB_PORT', undef) + ); +} + +my $query = "SELECT council, COUNT(*) AS total, SUM(fixed) AS fixed + FROM (SELECT council, + CASE WHEN state in ('fixed','fixed - user', 'fixed - council') + THEN 1 ELSE 0 END AS fixed + FROM problem WHERE confirmed IS NOT NULL AND + state IN ('fixed', 'fixed - user', 'fixed - council', 'confirmed') AND + whensent < NOW() - INTERVAL '4 weeks') AS a + GROUP BY council"; + +my $stats = dbh()->selectall_arrayref($query, { Slice => {} }); + +my @councils; +foreach my $row (@$stats) { + if ($row->{council}) { + $row->{council} =~ s/\|.*//g; + my @council_ids = split(/,/, $row->{council}); + push(@councils, @council_ids); + $row->{council} = \@council_ids; + } +} +my $areas_info = mySociety::MaPit::call('areas', \@councils); +my %adminsum; +my %adminfixed; +foreach my $row (@$stats){ + if ($row->{council}) { + for my $councilid (@{$row->{council}}) { + $adminsum{$councilid} += $row->{total}; + $adminfixed{$councilid} += $row->{fixed}; + } + } +} + +foreach my $councilid (sort sort_councils keys %adminsum) { + my $council = $areas_info->{$councilid}->{name}; + my $total = $adminsum{$councilid}; + my $fixed = $adminfixed{$councilid}; + printf("%5.1f %4d %s (%d)\n", 100 * $fixed / $total, $total, + $council, $councilid); +} + +sub sort_councils { + my $retval = ($adminfixed{$b} / $adminsum{$b}) <=> + ($adminfixed{$a} / $adminsum{$a}); + $retval = $adminsum{$b} <=> $adminsum{$a} unless $retval; + $retval = strcoll($areas_info->{$a}->{name}, + $areas_info->{$b}->{name}) unless $retval; + return $retval; +} diff --git a/bin/fixmystreet.com/update-areas b/bin/fixmystreet.com/update-areas new file mode 100755 index 000000000..a8cc01769 --- /dev/null +++ b/bin/fixmystreet.com/update-areas @@ -0,0 +1,46 @@ +#!/usr/bin/perl -w + +# update-areas: +# One-off script to populate the areas column of the problem table +# +# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. +# Email: matthew@mysociety.org. WWW: http://www.mysociety.org +# +# $Id: update-areas,v 1.1 2007-08-24 12:27:30 matthew Exp $ + +use strict; +require 5.8.0; + +# Horrible boilerplate to set up appropriate library paths. +use FindBin; +use lib "$FindBin::Bin/../perllib"; +use lib "$FindBin::Bin/../commonlib/perllib"; + +use mySociety::Config; +use mySociety::DBHandle qw(dbh select_all); +use mySociety::MaPit; +use mySociety::VotingArea; + +BEGIN { + mySociety::Config::set_file("$FindBin::Bin/../conf/general"); + mySociety::DBHandle::configure( + Name => mySociety::Config::get('FMS_DB_NAME'), + User => mySociety::Config::get('FMS_DB_USER'), + Password => mySociety::Config::get('FMS_DB_PASS'), + Host => mySociety::Config::get('FMS_DB_HOST', undef), + Port => mySociety::Config::get('FMS_DB_PORT', undef) + ); +} + +print "Fetching problems...\n"; +my $ids = select_all("select id, latitude, longitude from problem where areas=''"); +print "Updating areas...\n"; +my $c = 0; +foreach (@$ids) { + my $areas = mySociety::MaPit::get_voting_areas_by_location({latitude=>$_->{latitude}, longitude=>$_->{longitude}}, 'polygon'); + $areas = ',' . join(',', sort keys %$areas) . ','; + dbh()->do('update problem set areas=? where id=?', {}, $areas, $_->{id}); + dbh()->commit(); + print "Done: " . (++$c) . "/" . @$ids . "\n"; +} + diff --git a/bin/fixmystreet.com/update-send-questionnaire b/bin/fixmystreet.com/update-send-questionnaire new file mode 100755 index 000000000..7a231b919 --- /dev/null +++ b/bin/fixmystreet.com/update-send-questionnaire @@ -0,0 +1,29 @@ +#!/usr/bin/env perl + +=head1 DESCRIPTION + +Ad hoc script to update the send_questionnaire column on the +reports in cobrands that don't send questionnaires at all. + +=cut + +use strict; +use warnings; + +use FixMyStreet::App; + +my @cobrands; +foreach my $cobrand ( FixMyStreet::Cobrand->available_cobrand_classes() ) { + next unless $cobrand->{class}; + my $cls = $cobrand->{class}->new(); + push @cobrands, $cls->moniker if !$cls->send_questionnaires(); +} + +my $problems = FixMyStreet::App->model('DB::Problem')->search({ + cobrand => \@cobrands, + send_questionnaire => 1, +}); + +$problems->update( { + send_questionnaire => 0 +}); diff --git a/bin/generate_council_location b/bin/generate_council_location deleted file mode 100755 index c7aea8074..000000000 --- a/bin/generate_council_location +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/perl - -use strict; -use JSON; -use LWP::Simple; - -my $id = shift; - -my $url = sprintf( 'http://mapit.mysociety.org/area/%s/geometry', $id); - -my $json = get( $url ); -my $geo = decode_json( $json ); - -my $max_lat = $geo->{max_lat}; -my $min_lat = $geo->{min_lat}; -my $max_lon = $geo->{max_lon}; -my $min_lon = $geo->{min_lon}; -my $c_lat = $geo->{centre_lat}; -my $c_lon = $geo->{centre_lon}; - -my $spn_lat = $max_lat - $min_lat; -my $spn_lon = $max_lon - $min_lon; - -print <<"EOT"; - centre => '$c_lat,$c_lon', - span => '$spn_lat,$spn_lon', - bounds => [ $min_lat, $min_lon, $max_lat, $max_lon ], -EOT diff --git a/bin/import-categories b/bin/import-categories deleted file mode 100755 index e9008b93f..000000000 --- a/bin/import-categories +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/perl -w - -# import-categories: -# Initial choice of categories for councils. Most likely wrong. -# -# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. -# Email: matthew@mysociety.org. WWW: http://www.mysociety.org -# -# $Id: import-categories,v 1.3 2007-08-02 11:44:59 matthew Exp $ - -use strict; -require 5.8.0; - -# Horrible boilerplate to set up appropriate library paths. -use FindBin; -use lib "$FindBin::Bin/../perllib"; -use lib "$FindBin::Bin/../commonlib/perllib"; - -use mySociety::Config; -use mySociety::DBHandle qw(dbh select_all); -use mySociety::MaPit; -use mySociety::VotingArea; - -BEGIN { - mySociety::Config::set_file("$FindBin::Bin/../conf/general"); - mySociety::DBHandle::configure( - Name => mySociety::Config::get('FMS_DB_NAME'), - User => mySociety::Config::get('FMS_DB_USER'), - Password => mySociety::Config::get('FMS_DB_PASS'), - Host => mySociety::Config::get('FMS_DB_HOST', undef), - Port => mySociety::Config::get('FMS_DB_PORT', undef) - ); -} - -my @district_cats = ( - 'Abandoned vehicles', 'Car parking', 'Dog fouling', 'Flyposting', 'Flytipping', - 'Graffiti', 'Parks/landscapes', 'Public toilets', 'Rubbish (refuse and recycling)', - 'Street nameplates', 'Street cleaning', 'Trees' -); -my @county_cats = ( - 'Bus stops', 'Pavements/footpaths', 'Potholes', 'Roads/highways', - 'Road traffic signs', 'Street lighting', 'Traffic lights' -); - -my @councils; -foreach my $type (@$mySociety::VotingArea::council_parent_types) { - my $areas = mySociety::MaPit::get_areas_by_type($type); - push @councils, @$areas; -} -my $councils = mySociety::MaPit::get_voting_areas_info(\@councils); -foreach my $id (keys %$councils) { - my $type = $councils->{$id}->{type}; - my ($email,$confirmed) = dbh()->selectrow_array( - "SELECT email,confirmed FROM contacts WHERE deleted='f' - and area_id=? AND category='Other'", {}, $id); - next unless $email; - if ($type eq 'DIS') { - add_categories($id, $email, $confirmed, @district_cats); - } elsif ($type eq 'CTY') { - add_categories($id, $email, $confirmed, @county_cats); - } else { - add_categories($id, $email, $confirmed, @district_cats, @county_cats); - } -} -dbh()->commit(); - -sub add_categories { - my ($id, $email, $confirmed, @cats) = @_; - foreach (@cats) { - dbh()->do("insert into contacts - (area_id, category, email, editor, whenedited, note, confirmed, deleted) - values - (?, ?, ?, 'import', ms_current_timestamp(), 'Initial copy', ?, 'f')", {}, - $id, $_, $email, ($confirmed ? 1 : 0) - ); - } -} - diff --git a/bin/install-as-user b/bin/install-as-user index ef97a41b3..33a74c140 100755 --- a/bin/install-as-user +++ b/bin/install-as-user @@ -134,7 +134,7 @@ echo $DONE_MSG # Generate po and mo files (these invocations taken from Kagee's script): echo "Creating locale .mo files" bin/cron-wrapper bin/make_po FixMyStreet-EmptyHomes -bin/cron-wrapper bin/make_emptyhomes_welsh_po +bin/cron-wrapper bin/emptyhomes/make_welsh_po commonlib/bin/gettext-makemo FixMyStreet echo $DONE_MSG diff --git a/bin/kasabi b/bin/kasabi deleted file mode 100755 index 456b2f4d1..000000000 --- a/bin/kasabi +++ /dev/null @@ -1,234 +0,0 @@ -#!/usr/bin/env python - -import sys -import datetime -import json -import os.path -import re -import urllib -import yaml - -import pytassium -import psycopg2 -import psycopg2.extras -from rdfchangesets import BatchChangeSet -from rdflib.namespace import XSD - -# Set up data access -config = yaml.load(open(os.path.abspath(os.path.join(os.path.dirname(__file__), '../conf/general.yml')))) -dataset = pytassium.Dataset('fixmystreet', config['KASABI_API_KEY']) -db = psycopg2.connect( "host='{host}' dbname='{name}' user='{user}' password='{password}'".format( - host=config['FMS_DB_HOST'], - name=config['FMS_DB_NAME'], - user=config['FMS_DB_USER'], - password=config['FMS_DB_PASS'] -)) -cursor = db.cursor(cursor_factory=psycopg2.extras.RealDictCursor) -report_cursor = db.cursor(cursor_factory=psycopg2.extras.RealDictCursor) - -def main(): - - # Check the status of our dataset - response, status = dataset.status() - if response.status not in range(200, 300) or status['storageMode'] == 'read-only': - # We can't import anything, so let's not bother - sys.exit() - - # Fetch reports that have changed since last update in dataset - response, data = dataset.select('select (max(?lastupdate) as ?max) where { ?report ?lastupdate }') - max_lastUpdate = data[1][0]['max'] - query = """ - SELECT id, latitude, longitude, used_map, council, - category, title, detail, (photo IS NOT NULL) as photo, - confirmed, lastupdate, whensent, state - FROM problem - WHERE state not in ('unconfirmed', 'partial') - """ - if len(sys.argv) > 1 and sys.argv[1].isdigit(): - cursor.execute("%s AND id=%%s" % query, (sys.argv[1],)) - else: - cursor.execute("%s AND lastupdate > %%s ORDER BY lastupdate" % query, (str(max_lastUpdate),)) - - for report in cursor: - changeset = FixMyStreetChangeSet(dataset) - if report['state'] == 'hidden': - # If the report has been hidden, just remove it - changeset.remove_report(report) - else: - - # Canonicalise some values - report['latitude'] = round(report['latitude'], 6) # <10cm - report['longitude'] = round(report['longitude'], 6) - report['title'] = tidy_string(report['title']) - report['detail'] = tidy_string(report['detail']) - report['confirmed'] = report['confirmed'].replace(microsecond=0).isoformat() # Don't want microseconds - report['lastupdate'] = report['lastupdate'].replace(microsecond=0).isoformat() - report['council'] = sorted(re.sub('\|.*', '', report['council'] or '').split(',')) # Remove missing councils - - # Fetch updates to note state changes - states = [ { 'state': 'confirmed', 'time': report['confirmed'] } ] - report_cursor.execute(""" - SELECT id, mark_fixed, mark_open, problem_state, confirmed - FROM comment - WHERE problem_id=%s AND state='confirmed' - ORDER BY created - """, (report['id'], )) - for update in report_cursor: - t = update['confirmed'].replace(microsecond=0).isoformat() - if update['problem_state']: - states.append( { 'state': update['problem_state'], 'time': t } ) - elif update['mark_fixed']: - states.append( { 'state': 'fixed - user', 'time': t } ) - elif update['mark_open']: - states.append( { 'state': 'confirmed', 'time': t } ) - - # Remove and then re-add the report - changeset.remove_report(report) - changeset.add_report(report, states) - changeset.apply() - -# Escape double quotes and backslashes, remove carriage returns -def tidy_string(s): - return s.replace('\r', '').replace('\\', '\\\\').replace('"', r'\"') - -class FixMyStreetChangeSet(object): - """Something that hosts either or both of a BatchChangeSet and a Turtle - string for sending to Kasabi. Changes are done by removing all triples - and then readding the report.""" - _changeset = None - data = '' - - def __init__(self, dataset): - self.dataset = dataset - - def __str__(self): - return unicode(self).encode('utf-8') - - def __unicode__(self): - g = self.changeset.getGraph() - data = g.serialize(format='xml') - return "Changeset:\n" + data + "\nNew data:\n" + self.data - - @property - def changeset(self): - if not self._changeset: - self._changeset = BatchChangeSet() - self._changeset.setChangeReason("Report updates") - self._changeset.setCreatorName("FixMyStreet") - return self._changeset - - def apply(self): - if len(self.changeset.changesets): - #response, data = self.dataset.apply_changeset(self.changeset) - # XXX Do everything the above call does, but additionally escape carriage returns to prevent 409 error - api = self.dataset.get_api('update') - g = self.changeset.getGraph() - data = g.serialize(format='xml') - data = data.replace('\r', ' ') - response, data = api.client.request(api.uri, "POST", body=data, headers={"accept" : "*/*", 'content-type':'application/vnd.talis.changeset+xml', 'X_KASABI_APIKEY':api.apikey}) - if response.status not in range(200, 300): - print 'Error:', response.status, response.reason, data - if self.data: - response, data = self.dataset.store_data(self.data, media_type='text/turtle') - if response.status not in range(200, 300): - print 'Error:', response.status, response.reason, data - - def remove_report(self, report): - uri = 'http://data.kasabi.com/dataset/fixmystreet/report/{id}'.format(**report) - response, data = self.dataset.select('select ?p ?o where {{ <{0}> ?p ?o }}'.format(uri)) - for row in data[1]: - # Need to set the datatype correctly for the lastUpdate - if str(row['p']) == 'http://data.kasabi.com/dataset/fixmystreet/def/lastUpdate': - row['o'].datatype = XSD.dateTime - # Delete the referenced statuses - if re.match('http://data.kasabi.com/dataset/fixmystreet/report/\d+/status/\d+$', unicode(row['o'])): - uri2 = unicode(row['o']) - response2, data2 = self.dataset.select('select ?p ?o where {{ <{0}> ?p ?o }}'.format(uri2)) - for row2 in data2[1]: - self.changeset.remove(uri2, row2['p'], row2['o']) - self.changeset.remove(uri, row['p'], row['o']) - - def add_report(self, report, states): - # Work out the update states - c = 0 - state_data = { 'refs': '', 'objs': '' } - for state in states: - state_data['refs'] += ' ; fixmystreet:status \n'.format(id=report['id'], c=c) - obj = re.sub('[ -]', '', ' '.join(x.capitalize() for x in state['state'].split())) - if obj == 'Confirmed': obj = 'Open' - state_data['objs'] += """ a fixmystreet:{state}Status - ; event:time - . -""".format( id=report['id'], c=c, state=obj, time=state['time'] ) - # ; rdfs:label - c += 1 - - # Get info for the councils - council_data = { 'sentTo': '', 'areaNames': [] } - for council in report['council']: - if not council: continue - js = json.load(urllib.urlopen('http://mapit.mysociety.org/area/{0}'.format(council))) - os_id = int(js['codes']['unit_id']) + 7000000000000000 - if report['whensent']: - council_data['sentTo'] += ' ; fixmystreet:sentTo \n'.format(os_id=os_id) - council_data['areaNames'].append(js['name']) - council_data.setdefault('firstCouncil', council) - council_data['areaNames'] = ' / '.join(council_data['areaNames']) - council_data.setdefault('firstCouncil', '0') - -# easting/northing - - self.data += ''' -@prefix fixmystreet: . -@prefix dct: . -@prefix event: . -@prefix geo: . -@prefix xsd: . -@prefix skos: . -@prefix foaf: . -@prefix georss: . -@prefix owl: . - - a fixmystreet:Report - ; fixmystreet:location - ; dct:description """{detail}""" - ; dct:title "{title}" -{photo_url} -{state_data[refs]} -{council_data[sentTo]} - ; fixmystreet:category - ; fixmystreet:lastUpdate "{lastupdate}"^^xsd:dateTime - ; foaf:page - . - - a fixmystreet:Location - ; geo:lat "{latitude}" - ; geo:long "{longitude}" - ; georss:point "{latitude} {longitude}" - . - - - owl:sameAs - . -{state_data[objs]} - a skos:Concept - ; skos:prefLabel "{category}" - ; skos:altLabel "{category} in {council_data[areaNames]}" - . - '''.format( - photo_url = ' ; foaf:depiction '.format(**report) if report['photo'] else '', - state_data = state_data, - council_data = council_data, - category_uri = report['category'].lower().replace(' ', '-'), - **report - ) - -# ; skos:broader - -# this category is the broadest highlevel street light category -# a skos:Concept -# ; skos:prefLabel "Street lights" -# . - -main() - diff --git a/bin/load-contacts b/bin/load-contacts deleted file mode 100755 index b18699db1..000000000 --- a/bin/load-contacts +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/perl -w - -# canonicalise-csv: -# Convert provided CSV file into one with standard names for MaPit -# -# Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved. -# Email: matthew@mysociety.org. WWW: http://www.mysociety.org -# -# $Id: load-contacts,v 1.3 2007-08-02 11:44:59 matthew Exp $ - -use strict; -require 5.8.0; - -# Horrible boilerplate to set up appropriate library paths. -use FindBin; -use lib "$FindBin::Bin/../perllib"; -use lib "$FindBin::Bin/../commonlib/perllib"; - -use mySociety::Config; -use mySociety::DBHandle qw(dbh select_all); -use mySociety::Random; - -BEGIN { - mySociety::Config::set_file("$FindBin::Bin/../conf/general"); - mySociety::DBHandle::configure( - Name => mySociety::Config::get('FMS_DB_NAME'), - User => mySociety::Config::get('FMS_DB_USER'), - Password => mySociety::Config::get('FMS_DB_PASS'), - Host => mySociety::Config::get('FMS_DB_HOST', undef), - Port => mySociety::Config::get('FMS_DB_PORT', undef) - ); - - if (!dbh()->selectrow_array('select secret from secret for update of secret')) { - local dbh()->{HandleError}; - dbh()->do('insert into secret (secret) values (?)', {}, unpack('h*', mySociety::Random::random_bytes(32))); - } - dbh()->commit(); -} - -open(FP, "$FindBin::Bin/../data/councils_canonical.csv"); -while () { - s/\r?\n//g; - my ($id, $email) = split /,/; - dbh()->do("INSERT INTO contacts (area_id, email, editor, whenedited, note) - VALUES (?, ?, 'import', ms_current_timestamp(), 'Initial import')", - {}, $id, $email); -} -dbh()->commit(); -close(FP); diff --git a/bin/load-norwegian-contacts b/bin/load-norwegian-contacts deleted file mode 100755 index b73778848..000000000 --- a/bin/load-norwegian-contacts +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/perl -w - -# load-norwegian-contacts: -# Load initial contact list into fiksgatami. -# The format is -# Name;ID;email-address;Category1,Category2,... -# -# Based on script load-contacts copyright (c) 2006 UK Citizens Online Democracy. -# Copyright 2011 Petter Reinholdtsen -# -# $Id: load-norwegian-contacts,v 1.0 2007-08-02 11:44:59 matthew Exp $ - -use strict; -require 5.8.0; - -# Horrible boilerplate to set up appropriate library paths. -use FindBin; -use lib "$FindBin::Bin/../perllib"; -use lib "$FindBin::Bin/../commonlib/perllib"; - -use mySociety::Config; -use mySociety::DBHandle qw(dbh select_all); -use mySociety::Random; - -BEGIN { - mySociety::Config::set_file("$FindBin::Bin/../conf/general"); - mySociety::DBHandle::configure( - Name => mySociety::Config::get('FMS_DB_NAME'), - User => mySociety::Config::get('FMS_DB_USER'), - Password => mySociety::Config::get('FMS_DB_PASS'), - Host => mySociety::Config::get('FMS_DB_HOST', undef), - Port => mySociety::Config::get('FMS_DB_PORT', undef) - ); - - if (!dbh()->selectrow_array('select secret from secret for update of secret')) { - local dbh()->{HandleError}; - dbh()->do('insert into secret (secret) values (?)', {}, unpack('h*', mySociety::Random::random_bytes(32))); - } - dbh()->commit(); -} - -my $datafile = shift; -my $defcategories; -open(FP, "<", $datafile) or die "Unable to read from $datafile"; -while () { - s/\r?\n//g; - print "Loading $_\n"; - my ($id, $name, $email, $categories) = split /;/; - if (0 == $id) { - $defcategories = $categories; - next; - } - unless ($categories) { - $categories = $defcategories; - } -# dbh()->do("INSERT INTO contacts (area_id, email, editor, whenedited, note, confirmed, deleted) -# VALUES (?, ?, 'import', ms_current_timestamp(), 'Initial import', 'false', 'false')", -# {}, $id, $email); -# } else { - for my $category (split(/,\s*/, $categories)) { - print " Category '$category'\n"; - dbh()->do("INSERT INTO contacts (area_id, email, category, editor, whenedited, note, confirmed, deleted) - VALUES (?, ?, ?, 'import', ms_current_timestamp(), 'Initial import', 'true', 'false')", - {}, $id, $email, $category); - } -# } -} -dbh()->commit(); -close(FP); diff --git a/bin/make_emptyhomes_welsh_po b/bin/make_emptyhomes_welsh_po deleted file mode 100755 index f4f6850d6..000000000 --- a/bin/make_emptyhomes_welsh_po +++ /dev/null @@ -1,114 +0,0 @@ -#!/usr/bin/perl -w -use strict; - -# Given a translation of the Empty Homes version of the FixMyStreet .po file, -# fix it all up to go direct from FixMyStreet -> EH translation. - -use POSIX; -use FindBin; -use lib "$FindBin::Bin/../perllib"; -use PoChange; - -chdir("$FindBin::Bin/../locale"); - -# First read in translation and match up. -open(INPO, 'cy_GB.UTF-8/LC_MESSAGES/EmptyHomes.po') or die $!; - -my $state = 'start'; -my $msgid = ''; -my $fuzzy = 0; -my $msgstr; -my %lookup; -while () { - if (m/^#, fuzzy/) { - $fuzzy = 1; - } elsif (m/^#/) { - # comment or blank line - } elsif (m/^\s+$/) { - # blank line separates translations - $msgid =~ s/"\n"//g; - $lookup{$msgid} = [ $msgstr, $fuzzy ]; - $state = 'msgid'; - $msgid = ""; - $fuzzy = 0; - } elsif ($state eq 'msgid' && (m/^msgstr "/ || m/^msgstr\[0\] "/)) { - $msgstr = $_; - $state = 'msgstr'; - } elsif ($state eq 'msgstr') { - $msgstr .= $_; - } elsif ($state eq 'msgid') { - $msgid .= $_; - } -} -$lookup{$msgid} = [ $msgstr, $fuzzy ]; -close INPO; - -mkdir("en_GB.UTF-8"); -mkdir("en_GB.UTF-8/LC_MESSAGES"); -mkdir("cy_GB.UTF-8"); -mkdir("cy_GB.UTF-8/LC_MESSAGES"); - -open(MAINPO, 'FixMyStreet.po') or die; -open(OUTPO, ">cy_GB.UTF-8/LC_MESSAGES/FixMyStreet-EmptyHomes.po") or die; - -print OUTPO "# AUTOMATICALLY GENERATED by make_emptyhomes_welsh_po, do not edit\n\n"; - -my $buffer = ""; -my $start = 0; -while() { - if (!$start) { - s/#, fuzzy/#/; - } - if (m/"Last-Translator: FULL NAME/) { - $_ = '"Last-Translator: mysociety/bin/make_emptyhomes_po\\n"'."\n"; - } - if (m/"PO-Revision-Date: YEAR-MO-DA/) { - my $time = POSIX::strftime("%Y-%m-%d %H:%M%z", localtime(time())); - $_ = '"PO-Revision-Date: '.$time.'\\n"'."\n"; - } - if (m/"Language-Team: LANGUAGE/) { - $_ = '"Language-Team: mySociety\\n"'."\n"; - } - if (m/"Plural-Forms: nplurals=/) { - $_ = '"Plural-Forms: nplurals=2; plural=n != 1;\\n"'."\n"; - } - - if (m/^#/) { - # comment or blank line - print OUTPO $_; - } elsif (m/^\s+$/) { - # blank line - $start = 1; - $buffer = ""; - print OUTPO $_; - } elsif ($start && (m/^msgstr "/ || m/^msgstr\[0\] "/)) { - # start of translated text - translate English into Empty Homes language - my $new_buffer = PoChange::fixmystreet_to_reportemptyhomes($buffer); - $new_buffer =~ s/"\n"//g; - - if ($lookup{$new_buffer} && $lookup{$new_buffer}[1]) { - print OUTPO "#, fuzzy\n"; - } - - print OUTPO $buffer; - if ($lookup{$new_buffer}) { - print OUTPO $lookup{$new_buffer}[0]; - } else { - if (m/^msgstr\[0\] ""/) { - $new_buffer =~ s/^msgid "/msgstr[0] "/m; - $new_buffer =~ s/^msgid_plural "/msgstr[1] "/m; - $_ = ; # skip untranslated plural - } else { - $new_buffer =~ s/^msgid "/msgstr "/; - } - print OUTPO $new_buffer; - } - - $buffer = ""; - } elsif (!$start) { - print OUTPO $_; - } else { - $buffer .= $_; - } -} - diff --git a/bin/populate_bing_cache b/bin/populate_bing_cache deleted file mode 100755 index 17c8911d0..000000000 --- a/bin/populate_bing_cache +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; -require 5.8.0; - -use Data::Dumper; - -use FixMyStreet::App; -use FixMyStreet::Geocode::Bing; - -my $bing_culture = 'en-GB'; - -my $reports = FixMyStreet::App->model('DB::Problem')->search( - { - geocode => undef, - confirmed => { '!=', undef }, - latitude => { '!=', 0 }, - longitude => { '!=', 0 }, - }, - { - select => [qw/id geocode confirmed latitude longitude/], - order_by => { -desc => 'confirmed' } - } -); - -my $num_reports = $reports->count(); -print "Found $num_reports lacking geocode information\n"; - -my $time_to_do = ( $num_reports * 10 ) / 60 / 60; -if ( $time_to_do > 24 ) { - my $days = $time_to_do / 24; - my $hours = $time_to_do % 24; - printf( "Should take %d days and %d hours to finish\n", $days, $hours ); -} -elsif ( $time_to_do < 1 ) { - printf( "Should take %d minutes to finish\n", $time_to_do * 60 ); -} -else { - my $mins = ( $num_reports * 10 ) / 60 % 60; - printf( "Should take %d hours and %d minutes to finish\n", - $time_to_do, $mins ); -} - -while ( my $report = $reports->next ) { - $num_reports--; - next unless $report->latitude && $report->longitude; - next if $report->geocode; - - my $j = FixMyStreet::Geocode::Bing::reverse( $report->latitude, - $report->longitude, $bing_culture ); - - $report->geocode($j); - $report->update; - - print "$num_reports left to populate\n" unless $num_reports % 100; - sleep 10; -} - -print "done\n"; diff --git a/bin/rotate-photos b/bin/rotate-photos deleted file mode 100755 index 7b8109d65..000000000 --- a/bin/rotate-photos +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/perl -w - -# rotate-photos: -# Manaully fix any already-uploaded photos that are orientated wrongly. -# -# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. -# Email: matthew@mysociety.org. WWW: http://www.mysociety.org -# -# $Id: rotate-photos,v 1.1 2008-12-11 15:18:40 matthew Exp $ - -use strict; -require 5.8.0; - -# Horrible boilerplate to set up appropriate library paths. -use FindBin; -use lib "$FindBin::Bin/../perllib"; -use lib "$FindBin::Bin/../commonlib/perllib"; - -use Digest::SHA qw(sha1_hex); - -use Utils; -use mySociety::Config; -use mySociety::DBHandle qw(dbh select_all); -use mySociety::TempFiles; - -BEGIN { - mySociety::Config::set_file("$FindBin::Bin/../conf/general"); - mySociety::DBHandle::configure( - Name => mySociety::Config::get('FMS_DB_NAME'), - User => mySociety::Config::get('FMS_DB_USER'), - Password => mySociety::Config::get('FMS_DB_PASS'), - Host => mySociety::Config::get('FMS_DB_HOST', undef), - Port => mySociety::Config::get('FMS_DB_PORT', undef) - ); -} - -my $r = select_all("select id, photo from problem where service='iPhone'"); -foreach (@$r) { - my $id = $_->{id}; - my $photo = $_->{photo}; - - if (length($photo) == 40) { - # If photo field contains a hash - my $filename = mySociety::Config::get('UPLOAD_DIR') . "$photo.jpeg"; - `jhead -autorot $filename`; - } else { - my ($fh, $filename) = mySociety::TempFiles::named_tempfile('.jpeg'); - print $fh $photo; - close $fh; - my $out = `jhead -autorot $filename`; - if ($out) { - open(FP, $filename) or die $!; - $photo = join('', ); - close FP; - my $fileid = sha1_hex($photo); - rename $filename, mySociety::Config::get('UPLOAD_DIR') . "$fileid.jpeg"; - dbh()->do('UPDATE problem SET photo=? WHERE id=?', {}, $fileid, $id); - dbh()->commit(); - } else { - unlink $filename; - } - } -} - diff --git a/bin/showcouncilrates b/bin/showcouncilrates deleted file mode 100755 index 1dacae597..000000000 --- a/bin/showcouncilrates +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/perl - -use warnings; -use strict; - -use FindBin; -use lib "$FindBin::Bin/../perllib"; -use lib "$FindBin::Bin/../commonlib/perllib"; - -use POSIX qw(strcoll); -use mySociety::DBHandle qw(dbh); - -use mySociety::MaPit; -use FixMyStreet::Geocode::OSM; - -BEGIN { - mySociety::Config::set_file("$FindBin::Bin/../conf/general"); - mySociety::DBHandle::configure( - Name => mySociety::Config::get('FMS_DB_NAME'), - User => mySociety::Config::get('FMS_DB_USER'), - Password => mySociety::Config::get('FMS_DB_PASS'), - Host => mySociety::Config::get('FMS_DB_HOST', undef), - Port => mySociety::Config::get('FMS_DB_PORT', undef) - ); -} - -my $query = "SELECT council, COUNT(*) AS total, SUM(fixed) AS fixed - FROM (SELECT council, - CASE WHEN state in ('fixed','fixed - user', 'fixed - council') - THEN 1 ELSE 0 END AS fixed - FROM problem WHERE confirmed IS NOT NULL AND - state IN ('fixed', 'fixed - user', 'fixed - council', 'confirmed') AND - whensent < NOW() - INTERVAL '4 weeks') AS a - GROUP BY council"; - -my $stats = dbh()->selectall_arrayref($query, { Slice => {} }); - -my @councils; -foreach my $row (@$stats) { - if ($row->{council}) { - $row->{council} =~ s/\|.*//g; - my @council_ids = split(/,/, $row->{council}); - push(@councils, @council_ids); - $row->{council} = \@council_ids; - } -} -my $areas_info = mySociety::MaPit::call('areas', \@councils); -my %adminsum; -my %adminfixed; -foreach my $row (@$stats){ - if ($row->{council}) { - for my $councilid (@{$row->{council}}) { - $adminsum{$councilid} += $row->{total}; - $adminfixed{$councilid} += $row->{fixed}; - } - } -} - -foreach my $councilid (sort sort_councils keys %adminsum) { - my $council = $areas_info->{$councilid}->{name}; - my $total = $adminsum{$councilid}; - my $fixed = $adminfixed{$councilid}; - printf("%5.1f %4d %s (%d)\n", 100 * $fixed / $total, $total, - $council, $councilid); -} - -sub sort_councils { - my $retval = ($adminfixed{$b} / $adminsum{$b}) <=> - ($adminfixed{$a} / $adminsum{$a}); - $retval = $adminsum{$b} <=> $adminsum{$a} unless $retval; - $retval = strcoll($areas_info->{$a}->{name}, - $areas_info->{$b}->{name}) unless $retval; - return $retval; -} diff --git a/bin/update-areas b/bin/update-areas deleted file mode 100755 index a8cc01769..000000000 --- a/bin/update-areas +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/perl -w - -# update-areas: -# One-off script to populate the areas column of the problem table -# -# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. -# Email: matthew@mysociety.org. WWW: http://www.mysociety.org -# -# $Id: update-areas,v 1.1 2007-08-24 12:27:30 matthew Exp $ - -use strict; -require 5.8.0; - -# Horrible boilerplate to set up appropriate library paths. -use FindBin; -use lib "$FindBin::Bin/../perllib"; -use lib "$FindBin::Bin/../commonlib/perllib"; - -use mySociety::Config; -use mySociety::DBHandle qw(dbh select_all); -use mySociety::MaPit; -use mySociety::VotingArea; - -BEGIN { - mySociety::Config::set_file("$FindBin::Bin/../conf/general"); - mySociety::DBHandle::configure( - Name => mySociety::Config::get('FMS_DB_NAME'), - User => mySociety::Config::get('FMS_DB_USER'), - Password => mySociety::Config::get('FMS_DB_PASS'), - Host => mySociety::Config::get('FMS_DB_HOST', undef), - Port => mySociety::Config::get('FMS_DB_PORT', undef) - ); -} - -print "Fetching problems...\n"; -my $ids = select_all("select id, latitude, longitude from problem where areas=''"); -print "Updating areas...\n"; -my $c = 0; -foreach (@$ids) { - my $areas = mySociety::MaPit::get_voting_areas_by_location({latitude=>$_->{latitude}, longitude=>$_->{longitude}}, 'polygon'); - $areas = ',' . join(',', sort keys %$areas) . ','; - dbh()->do('update problem set areas=? where id=?', {}, $areas, $_->{id}); - dbh()->commit(); - print "Done: " . (++$c) . "/" . @$ids . "\n"; -} - diff --git a/bin/update-send-questionnaire b/bin/update-send-questionnaire deleted file mode 100755 index 7a231b919..000000000 --- a/bin/update-send-questionnaire +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env perl - -=head1 DESCRIPTION - -Ad hoc script to update the send_questionnaire column on the -reports in cobrands that don't send questionnaires at all. - -=cut - -use strict; -use warnings; - -use FixMyStreet::App; - -my @cobrands; -foreach my $cobrand ( FixMyStreet::Cobrand->available_cobrand_classes() ) { - next unless $cobrand->{class}; - my $cls = $cobrand->{class}->new(); - push @cobrands, $cls->moniker if !$cls->send_questionnaires(); -} - -my $problems = FixMyStreet::App->model('DB::Problem')->search({ - cobrand => \@cobrands, - send_questionnaire => 1, -}); - -$problems->update( { - send_questionnaire => 0 -}); diff --git a/bin/zerotb/import_clinic_list.pl b/bin/zerotb/import_clinic_list.pl new file mode 100755 index 000000000..359a63925 --- /dev/null +++ b/bin/zerotb/import_clinic_list.pl @@ -0,0 +1,115 @@ +#!/usr/bin/perl + +use strict; +use FixMyStreet::App; +use Text::CSV; +use Getopt::Long::Descriptive; + +use constant TITLE => 0; +use constant DESC => 1; +use constant LATLONG => 2; +use constant EMAIL => 3; + +my ($opt, $usage) = describe_options( + '%c %o', + ['file|f=s', "path to csv file with list of clinics", { required => 1 } ], + ['email|e=s', "default email address for the updates to be sent to", { required => 1 } ], + ['verbose|v', "print out all services as they are found"], + ['help', "print usage message and exit" ], +); +print($usage->text), exit if $opt->help; + +my $csv = Text::CSV->new ( { binary => 1 } ) # should set binary attribute. + or die "Cannot use CSV: ".Text::CSV->error_diag (); +open my $fh, "<:encoding(utf8)", $opt->file or die "Failed to open " . $opt->file . ": $!"; + +my $clinic_user = FixMyStreet::App->model('DB::User')->find_or_create({ + email => $opt->email +}); +if ( not $clinic_user->in_storage ) { + $clinic_user->insert; +} + +# throw away header line +my $title_row = $csv->getline( $fh ); + +while ( my $row = $csv->getline( $fh ) ) { + my $clinics = FixMyStreet::App->model('DB::Problem')->search({ + title => $row->[TITLE] + }); + + my ($lat, $long) = split(',', $row->[LATLONG]); + my $p; + my $count = $clinics->count; + if ( $count == 0 ) { + $p = FixMyStreet::App->model('DB::Problem')->create({ + title => $row->[TITLE], + latitude => $lat, + longitude => $long, + used_map => 1, + anonymous => 1, + state => 'unconfirmed', + name => '', + user => $clinic_user, + detail => '', + areas => '', + postcode => '' + }); + } elsif ( $count == 1 ) { + $p = $clinics->first; + } else { + printf "Too many matches for: %s\n", $row->[TITLE]; + next; + } + $p->detail( $row->[DESC] ); + $p->latitude( $lat ); + $p->longitude( $long ); + $p->confirm; + + if ( $p->in_storage ) { + printf( "Updating entry for %s\n", $row->[TITLE] ) if $opt->verbose; + $p->update; + } else { + printf( "Creating entry for %s\n", $row->[TITLE] ) if $opt->verbose; + $p->insert; + } + $p->discard_changes; + + # disabling existing alerts in case email addresses have changed + my $existing = FixMyStreet::App->model('DB::Alert')->search({ + alert_type => 'new_updates', + parameter => $p->id + }); + $existing->update( { confirmed => 0 } ); + + if ( $row->[EMAIL] ) { + my $u = FixMyStreet::App->model('DB::User')->find_or_new({ + email => $row->[EMAIL] + }); + $u->insert unless $u->in_storage; + create_update_alert( $u, $p, $opt->verbose ); + } + + create_update_alert( $clinic_user, $p, $opt->verbose ); +} + +sub create_update_alert { + my ( $user, $p, $verbose ) = @_; + my $a = FixMyStreet::App->model('DB::Alert')->find_or_new({ + alert_type => 'new_updates', + user => $user, + parameter => $p->id, + }); + + $a->confirmed(1); + + if ( $a->in_storage ) { + printf( "Updating update alert for %s on %s\n", $user->email, $p->title ) + if $verbose; + $a->update; + } else { + printf( "Creating update alert for %s on %s\n", $user->email, $p->title ) + if $verbose; + $a->insert; + } +} diff --git a/bin/zerotb_import_clinic_list.pl b/bin/zerotb_import_clinic_list.pl deleted file mode 100755 index 359a63925..000000000 --- a/bin/zerotb_import_clinic_list.pl +++ /dev/null @@ -1,115 +0,0 @@ -#!/usr/bin/perl - -use strict; -use FixMyStreet::App; -use Text::CSV; -use Getopt::Long::Descriptive; - -use constant TITLE => 0; -use constant DESC => 1; -use constant LATLONG => 2; -use constant EMAIL => 3; - -my ($opt, $usage) = describe_options( - '%c %o', - ['file|f=s', "path to csv file with list of clinics", { required => 1 } ], - ['email|e=s', "default email address for the updates to be sent to", { required => 1 } ], - ['verbose|v', "print out all services as they are found"], - ['help', "print usage message and exit" ], -); -print($usage->text), exit if $opt->help; - -my $csv = Text::CSV->new ( { binary => 1 } ) # should set binary attribute. - or die "Cannot use CSV: ".Text::CSV->error_diag (); -open my $fh, "<:encoding(utf8)", $opt->file or die "Failed to open " . $opt->file . ": $!"; - -my $clinic_user = FixMyStreet::App->model('DB::User')->find_or_create({ - email => $opt->email -}); -if ( not $clinic_user->in_storage ) { - $clinic_user->insert; -} - -# throw away header line -my $title_row = $csv->getline( $fh ); - -while ( my $row = $csv->getline( $fh ) ) { - my $clinics = FixMyStreet::App->model('DB::Problem')->search({ - title => $row->[TITLE] - }); - - my ($lat, $long) = split(',', $row->[LATLONG]); - my $p; - my $count = $clinics->count; - if ( $count == 0 ) { - $p = FixMyStreet::App->model('DB::Problem')->create({ - title => $row->[TITLE], - latitude => $lat, - longitude => $long, - used_map => 1, - anonymous => 1, - state => 'unconfirmed', - name => '', - user => $clinic_user, - detail => '', - areas => '', - postcode => '' - }); - } elsif ( $count == 1 ) { - $p = $clinics->first; - } else { - printf "Too many matches for: %s\n", $row->[TITLE]; - next; - } - $p->detail( $row->[DESC] ); - $p->latitude( $lat ); - $p->longitude( $long ); - $p->confirm; - - if ( $p->in_storage ) { - printf( "Updating entry for %s\n", $row->[TITLE] ) if $opt->verbose; - $p->update; - } else { - printf( "Creating entry for %s\n", $row->[TITLE] ) if $opt->verbose; - $p->insert; - } - $p->discard_changes; - - # disabling existing alerts in case email addresses have changed - my $existing = FixMyStreet::App->model('DB::Alert')->search({ - alert_type => 'new_updates', - parameter => $p->id - }); - $existing->update( { confirmed => 0 } ); - - if ( $row->[EMAIL] ) { - my $u = FixMyStreet::App->model('DB::User')->find_or_new({ - email => $row->[EMAIL] - }); - $u->insert unless $u->in_storage; - create_update_alert( $u, $p, $opt->verbose ); - } - - create_update_alert( $clinic_user, $p, $opt->verbose ); -} - -sub create_update_alert { - my ( $user, $p, $verbose ) = @_; - my $a = FixMyStreet::App->model('DB::Alert')->find_or_new({ - alert_type => 'new_updates', - user => $user, - parameter => $p->id, - }); - - $a->confirmed(1); - - if ( $a->in_storage ) { - printf( "Updating update alert for %s on %s\n", $user->email, $p->title ) - if $verbose; - $a->update; - } else { - printf( "Creating update alert for %s on %s\n", $user->email, $p->title ) - if $verbose; - $a->insert; - } -} diff --git a/bin/zurich-overdue-alert b/bin/zurich-overdue-alert deleted file mode 100755 index c09aef1e2..000000000 --- a/bin/zurich-overdue-alert +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/env perl - -# zurich-overdue-alert: -# Send email alerts to administrators for overdue admin activities. -# -# Copyright (c) 2012 UK Citizens Online Democracy. All rights reserved. -# Email: matthew@mysociety.org. WWW: http://www.mysociety.org - -use strict; -use warnings; -require 5.8.0; - -use DateTime; -use CronFns; -use FixMyStreet::App; - -my ($verbose, $nomail) = CronFns::options(); - -# Only run on working days -my $now = DateTime->now(); -exit if FixMyStreet::Cobrand::Zurich::is_public_holiday($now) or FixMyStreet::Cobrand::Zurich::is_weekend($now); - -my $cobrand = FixMyStreet::Cobrand->get_class_for_moniker('zurich')->new(); -my %bodies = map { $_->id => $_ } FixMyStreet::App->model("DB::Body")->all; - -loop_through( 'alert-moderation-overdue.txt', 0, 1, [ 'unconfirmed' ] ); -loop_through( 'alert-overdue.txt', 1, 6, 'in progress' ); -loop_through( 'alert-overdue.txt', 0, 6, ['confirmed', 'planned'] ); - -sub loop_through { - my ( $template, $include_parent, $days, $states ) = @_; - my $dtf = FixMyStreet::App->model("DB")->storage->datetime_parser; - my $date_threshold = $dtf->format_datetime(FixMyStreet::Cobrand::Zurich::sub_days( $now, $days )); - - my $reports = FixMyStreet::App->model("DB::Problem")->search( { - state => $states, - created => { '<', $date_threshold }, - bodies_str => { '!=', undef }, - } ); - - my %to_send = (); - while (my $row = $reports->next) { - $to_send{$row->bodies_str} .= '* ' . $row->id . ": '" . $row->title . "'\n\n"; - } - - my $template_path = FixMyStreet->path_to( "templates", "email", "zurich", $template )->stringify; - $template = Utils::read_file( $template_path ); - - foreach my $body_id (keys %to_send) { - send_alert( $template, $body_id, $to_send{$body_id}, $include_parent ); - } -} - -sub send_alert { - my ( $template, $body_id, $data, $include_parent ) = @_; - - my $body = $bodies{$body_id}; - my $body_email = $body->endpoint; - - my $h = { - data => $data, - admin_url => $cobrand->admin_base_url, - }; - - my $to = [ [ $body_email, $body->name ] ]; - if ( $include_parent ) { - my $parent = $body->parent; - my $parent_email = $parent->endpoint; - push @$to, [ $parent_email, $parent->name ]; - } - - FixMyStreet::App->send_email_cron( - { - _template_ => $template, - _parameters_ => $h, - To => $to, - From => [ FixMyStreet->config('CONTACT_EMAIL'), FixMyStreet->config('CONTACT_NAME') ], - }, - FixMyStreet->config('CONTACT_EMAIL'), - $nomail - ); -} - diff --git a/bin/zurich/geocode b/bin/zurich/geocode deleted file mode 100755 index 9482b27e6..000000000 --- a/bin/zurich/geocode +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/perl - -=head1 NAME - -zurich/geocode - commandline tool to test the Zurich geocoder - -=head1 SYNOPSIS - - # Firstly: - ## copy the GEOCODER config from a current Zurich conf to your conf/general.yml - $ eval `perl setenv.pl` - - $ bin/zurich/geocode Magnus - - # ... output from geocoder - -This can be used to test the results of, e.g. - - https://www.zueriwieneu.ch/ajax/geocode?term=Magnus - -but without the caching which FixMyStreet applies, and passing on any 500 -errors from the server. - -=cut - -use strict; -use warnings; -require 5.8.0; - - -use Data::Dumper; -use feature 'say'; - -use FixMyStreet; -use FixMyStreet::App; -use FixMyStreet::Geocode::Zurich; - -# TODO use FixMyStreet::override_config to get data from conf/general.yml.zurich if available -my $geocoder = FixMyStreet->config('GEOCODER') - or die "No GEOCODER config -- please copy appropriate Zurich conf to conf/general.yml"; - -my $c = FixMyStreet::App->new(); -my $s = join ' ', @ARGV; - -say Dumper( FixMyStreet::Geocode::Zurich::string( $s, $c ) ); diff --git a/bin/zurich/overdue-alert b/bin/zurich/overdue-alert new file mode 100755 index 000000000..fd9c26cb9 --- /dev/null +++ b/bin/zurich/overdue-alert @@ -0,0 +1,83 @@ +#!/usr/bin/env perl + +# zurich/overdue-alert: +# Send email alerts to administrators for overdue admin activities. +# +# Copyright (c) 2012 UK Citizens Online Democracy. All rights reserved. +# Email: matthew@mysociety.org. WWW: http://www.mysociety.org + +use strict; +use warnings; +require 5.8.0; + +use DateTime; +use CronFns; +use FixMyStreet::App; + +my ($verbose, $nomail) = CronFns::options(); + +# Only run on working days +my $now = DateTime->now(); +exit if FixMyStreet::Cobrand::Zurich::is_public_holiday($now) or FixMyStreet::Cobrand::Zurich::is_weekend($now); + +my $cobrand = FixMyStreet::Cobrand->get_class_for_moniker('zurich')->new(); +my %bodies = map { $_->id => $_ } FixMyStreet::App->model("DB::Body")->all; + +loop_through( 'alert-moderation-overdue.txt', 0, 1, [ 'unconfirmed' ] ); +loop_through( 'alert-overdue.txt', 1, 6, 'in progress' ); +loop_through( 'alert-overdue.txt', 0, 6, ['confirmed', 'planned'] ); + +sub loop_through { + my ( $template, $include_parent, $days, $states ) = @_; + my $dtf = FixMyStreet::App->model("DB")->storage->datetime_parser; + my $date_threshold = $dtf->format_datetime(FixMyStreet::Cobrand::Zurich::sub_days( $now, $days )); + + my $reports = FixMyStreet::App->model("DB::Problem")->search( { + state => $states, + created => { '<', $date_threshold }, + bodies_str => { '!=', undef }, + } ); + + my %to_send = (); + while (my $row = $reports->next) { + $to_send{$row->bodies_str} .= '* ' . $row->id . ": '" . $row->title . "'\n\n"; + } + + my $template_path = FixMyStreet->path_to( "templates", "email", "zurich", $template )->stringify; + $template = Utils::read_file( $template_path ); + + foreach my $body_id (keys %to_send) { + send_alert( $template, $body_id, $to_send{$body_id}, $include_parent ); + } +} + +sub send_alert { + my ( $template, $body_id, $data, $include_parent ) = @_; + + my $body = $bodies{$body_id}; + my $body_email = $body->endpoint; + + my $h = { + data => $data, + admin_url => $cobrand->admin_base_url, + }; + + my $to = [ [ $body_email, $body->name ] ]; + if ( $include_parent ) { + my $parent = $body->parent; + my $parent_email = $parent->endpoint; + push @$to, [ $parent_email, $parent->name ]; + } + + FixMyStreet::App->send_email_cron( + { + _template_ => $template, + _parameters_ => $h, + To => $to, + From => [ FixMyStreet->config('CONTACT_EMAIL'), FixMyStreet->config('CONTACT_NAME') ], + }, + FixMyStreet->config('CONTACT_EMAIL'), + $nomail + ); +} + diff --git a/data/kasabi-requirements.txt b/data/kasabi-requirements.txt deleted file mode 100644 index 9b4397f00..000000000 --- a/data/kasabi-requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -psycopg2 -pytassium diff --git a/perllib/FixMyStreet/DB/Result/Token.pm b/perllib/FixMyStreet/DB/Result/Token.pm index 5525fe7a5..0156af137 100644 --- a/perllib/FixMyStreet/DB/Result/Token.pm +++ b/perllib/FixMyStreet/DB/Result/Token.pm @@ -30,9 +30,6 @@ __PACKAGE__->set_primary_key("scope", "token"); # Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-03-08 17:19:55 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:+LLZ8P5GXqPetuGyrra2vw -# Trying not to use this -# use mySociety::DBHandle qw(dbh); - use mySociety::AuthToken; =head1 NAME @@ -43,8 +40,6 @@ FixMyStreet::DB::Result::Token Representation of mySociety::AuthToken in the DBIx::Class world. -Mostly done so that we don't need to use mySociety::DBHandle. - The 'data' value is automatically inflated and deflated in the same way that the AuthToken would do it. 'token' is set to a new random value by default and the 'created' timestamp is achieved using the database function diff --git a/perllib/Utils.pm b/perllib/Utils.pm index 8f0ac1820..6d6d5bcde 100644 --- a/perllib/Utils.pm +++ b/perllib/Utils.pm @@ -15,7 +15,6 @@ use strict; use DateTime; use Encode; use File::Slurp qw(); -use mySociety::DBHandle qw(dbh); use mySociety::GeoUtil; use mySociety::Locale; -- cgit v1.2.3