diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/fetch-comments | 3 | ||||
-rwxr-xr-x | bin/fetch-comments-24hs | 2 | ||||
-rwxr-xr-x | bin/fiksgatami/showroadinfo | 5 | ||||
-rwxr-xr-x | bin/fiksgatami/showroadstats | 5 | ||||
-rwxr-xr-x | bin/fixmystreet.com/populate_bing_cache | 4 | ||||
-rwxr-xr-x | bin/fixmystreet.com/update-send-questionnaire | 5 | ||||
-rwxr-xr-x | bin/open311-populate-service-list | 4 | ||||
-rwxr-xr-x | bin/open311-update-reports | 9 | ||||
-rwxr-xr-x | bin/problem-creation-graph | 4 | ||||
-rwxr-xr-x | bin/problems-filed-graph | 4 | ||||
-rwxr-xr-x | bin/send-alerts | 4 | ||||
-rwxr-xr-x | bin/send-comments | 13 | ||||
-rwxr-xr-x | bin/send-questionnaires | 6 | ||||
-rwxr-xr-x | bin/send-reports | 4 | ||||
-rwxr-xr-x | bin/update-all-reports | 6 | ||||
-rwxr-xr-x | bin/zerotb/import_clinic_list.pl | 14 | ||||
-rwxr-xr-x | bin/zurich/convert_internal_notes_to_comments | 8 | ||||
-rwxr-xr-x | bin/zurich/overdue-alert | 11 |
18 files changed, 53 insertions, 58 deletions
diff --git a/bin/fetch-comments b/bin/fetch-comments index 4eb9def14..55ba70d85 100755 --- a/bin/fetch-comments +++ b/bin/fetch-comments @@ -15,14 +15,11 @@ BEGIN { require "$d/../setenv.pl"; } -use FixMyStreet::App; use CronFns; my ($verbose, $nomail) = CronFns::options(); -use Open311; use Open311::GetServiceRequestUpdates; - my $updates = Open311::GetServiceRequestUpdates->new( verbose => $verbose ); $updates->fetch; diff --git a/bin/fetch-comments-24hs b/bin/fetch-comments-24hs index 27853bcc1..df208439e 100755 --- a/bin/fetch-comments-24hs +++ b/bin/fetch-comments-24hs @@ -19,11 +19,9 @@ BEGIN { use DateTime; use DateTime::Format::W3CDTF; -use FixMyStreet::App; use CronFns; my ($verbose, $nomail) = CronFns::options(); -use Open311; use Open311::GetServiceRequestUpdates; my $dt = DateTime->now(); diff --git a/bin/fiksgatami/showroadinfo b/bin/fiksgatami/showroadinfo index 658fca01c..fda6fbb6b 100755 --- a/bin/fiksgatami/showroadinfo +++ b/bin/fiksgatami/showroadinfo @@ -3,11 +3,12 @@ use strict; use warnings; -use FixMyStreet::App; +use FixMyStreet::Cobrand; +use FixMyStreet::DB; use FixMyStreet::Geocode::OSM; use Data::Dumper; -FixMyStreet::App->model('DB::Problem')->send_reports(); +FixMyStreet::DB->resultset('Problem')->send_reports(); my $cobrand = FixMyStreet::Cobrand->get_class_for_moniker('fiksgatami')->new(); diff --git a/bin/fiksgatami/showroadstats b/bin/fiksgatami/showroadstats index 83c3c4310..9bc8de70b 100755 --- a/bin/fiksgatami/showroadstats +++ b/bin/fiksgatami/showroadstats @@ -3,10 +3,11 @@ use strict; use warnings; -use FixMyStreet::App; +use FixMyStreet::Cobrand; +use FixMyStreet::DB; use FixMyStreet::Geocode::OSM; -my @reports = FixMyStreet::App->model('DB::Problem')->search({ +my @reports = FixMyStreet::DB->resultset('Problem')->search({ state => [ FixMyStreet::DB::Result::Problem->visible_states() ], }, { rows => 40, diff --git a/bin/fixmystreet.com/populate_bing_cache b/bin/fixmystreet.com/populate_bing_cache index 17c8911d0..c644b34fa 100755 --- a/bin/fixmystreet.com/populate_bing_cache +++ b/bin/fixmystreet.com/populate_bing_cache @@ -6,12 +6,12 @@ require 5.8.0; use Data::Dumper; -use FixMyStreet::App; +use FixMyStreet::DB; use FixMyStreet::Geocode::Bing; my $bing_culture = 'en-GB'; -my $reports = FixMyStreet::App->model('DB::Problem')->search( +my $reports = FixMyStreet::DB->resultset('Problem')->search( { geocode => undef, confirmed => { '!=', undef }, diff --git a/bin/fixmystreet.com/update-send-questionnaire b/bin/fixmystreet.com/update-send-questionnaire index 7a231b919..40549c6e4 100755 --- a/bin/fixmystreet.com/update-send-questionnaire +++ b/bin/fixmystreet.com/update-send-questionnaire @@ -10,7 +10,8 @@ reports in cobrands that don't send questionnaires at all. use strict; use warnings; -use FixMyStreet::App; +use FixMyStreet::Cobrand; +use FixMyStreet::DB; my @cobrands; foreach my $cobrand ( FixMyStreet::Cobrand->available_cobrand_classes() ) { @@ -19,7 +20,7 @@ foreach my $cobrand ( FixMyStreet::Cobrand->available_cobrand_classes() ) { push @cobrands, $cls->moniker if !$cls->send_questionnaires(); } -my $problems = FixMyStreet::App->model('DB::Problem')->search({ +my $problems = FixMyStreet::DB->resultset('Problem')->search({ cobrand => \@cobrands, send_questionnaire => 1, }); diff --git a/bin/open311-populate-service-list b/bin/open311-populate-service-list index 11f9005a5..211061258 100755 --- a/bin/open311-populate-service-list +++ b/bin/open311-populate-service-list @@ -10,7 +10,7 @@ BEGIN { require "$d/../setenv.pl"; } -use FixMyStreet::App; +use FixMyStreet::DB; use Open311::PopulateServiceList; use Getopt::Long::Descriptive; @@ -22,7 +22,7 @@ my ($opt, $usage) = describe_options( ); print($usage->text), exit if $opt->help; -my $bodies = FixMyStreet::App->model('DB::Body')->search( { +my $bodies = FixMyStreet::DB->resultset('Body')->search( { id => { '!=', 2237 }, # XXX Until Oxfordshire does do so send_method => 'Open311' } ); diff --git a/bin/open311-update-reports b/bin/open311-update-reports index 6a1c894d7..378f8e8bc 100755 --- a/bin/open311-update-reports +++ b/bin/open311-update-reports @@ -17,17 +17,18 @@ BEGIN { } use Open311::GetUpdates; -use FixMyStreet::App; +use FixMyStreet; +use FixMyStreet::DB; # FIXME - make this configurable and/or better -my $system_user = FixMyStreet::App->model('DB::User')->find_or_create( +my $system_user = FixMyStreet::DB->resultset('User')->find_or_create( { - email => FixMyStreet::App->config->{'CONTACT_EMAIL'}, + email => FixMyStreet->config('CONTACT_EMAIL'), name => 'System User', } ); -my $body_list = FixMyStreet::App->model('DB::Body'); +my $body_list = FixMyStreet::DB->resultset('Body'); my $update = Open311::GetUpdates->new( body_list => $body_list, diff --git a/bin/problem-creation-graph b/bin/problem-creation-graph index 3e46777f4..a8554058a 100755 --- a/bin/problem-creation-graph +++ b/bin/problem-creation-graph @@ -20,7 +20,7 @@ BEGIN { use File::Temp qw(tempfile); -use FixMyStreet::App; +use FixMyStreet::DB; my %config = ( gplot_output => "set terminal png font 'Vera.ttf' 9 size 1200,400", @@ -43,7 +43,7 @@ sub grab_data { my ($fh, $filename) = tempfile("fms-creation-rate-graph-data-XXXXXXXXXX", UNLINK => 1); $sources{$type} = $filename; - my @entries = FixMyStreet::App->model('DB::Problem')->search( + my @entries = FixMyStreet::DB->resultset('Problem')->search( $selection, { columns => [ { 'date' => { date => 'created' } }, diff --git a/bin/problems-filed-graph b/bin/problems-filed-graph index a930e4346..950797ebe 100755 --- a/bin/problems-filed-graph +++ b/bin/problems-filed-graph @@ -20,7 +20,7 @@ BEGIN { use File::Temp qw(tempfile); -use FixMyStreet::App; +use FixMyStreet::DB; my %config = ( gplot_output => "set terminal png font 'Vera.ttf' 9 size 1200,600", @@ -29,7 +29,7 @@ my %config = ( my ($fh, $source) = tempfile("fms-report-rate-graph-data-nonwmc-XXXXXXXXXX", UNLINK => 1); -my @entries = FixMyStreet::App->model('DB::Problem')->search({ +my @entries = FixMyStreet::DB->resultset('Problem')->search({ state => { -not_in => [ 'unconfirmed', 'hidden', 'partial' ] }, }, { columns => [ diff --git a/bin/send-alerts b/bin/send-alerts index 94f7d5509..b0040268a 100755 --- a/bin/send-alerts +++ b/bin/send-alerts @@ -21,10 +21,10 @@ use CGI; # XXX use CronFns; use mySociety::Config; -use FixMyStreet::App; +use FixMyStreet::DB; my $site = CronFns::site(mySociety::Config::get('BASE_URL')); CronFns::language($site); -FixMyStreet::App->model('DB::AlertType')->email_alerts(); +FixMyStreet::DB->resultset('AlertType')->email_alerts(); diff --git a/bin/send-comments b/bin/send-comments index fbbd57891..c3f21fb2c 100755 --- a/bin/send-comments +++ b/bin/send-comments @@ -20,15 +20,12 @@ BEGIN { require "$d/../setenv.pl"; } -use Digest::MD5; -use Encode; use CronFns; -use FixMyStreet::App; - -use Utils; use mySociety::Config; - +use DateTime; +use FixMyStreet::Cobrand; +use FixMyStreet::DB; use Open311; # send_method config values found in by-area config data, for selecting to appropriate method @@ -42,7 +39,7 @@ my ($verbose, $nomail) = CronFns::options(); my $base_url = mySociety::Config::get('BASE_URL'); my $site = CronFns::site($base_url); -my $bodies = FixMyStreet::App->model('DB::Body')->search( { +my $bodies = FixMyStreet::DB->resultset('Body')->search( { send_method => SEND_METHOD_OPEN311, send_comments => 1, } ); @@ -54,7 +51,7 @@ while ( my $body = $bodies->next ) { next if $body->areas->{+COUNCIL_ID_OXFORDSHIRE}; my $use_extended = 0; - my $comments = FixMyStreet::App->model('DB::Comment')->search( { + my $comments = FixMyStreet::DB->resultset('Comment')->search( { 'me.whensent' => undef, 'me.external_id' => undef, 'me.state' => 'confirmed', diff --git a/bin/send-questionnaires b/bin/send-questionnaires index 93d58ed77..141c21560 100755 --- a/bin/send-questionnaires +++ b/bin/send-questionnaires @@ -18,10 +18,8 @@ BEGIN { } use CGI; # XXX Awkward kludge -use Encode; use CronFns; - -use FixMyStreet::App; +use FixMyStreet::DB; use mySociety::Config; my %params; @@ -29,5 +27,5 @@ my %params; $params{site} = CronFns::site(mySociety::Config::get('BASE_URL')); CronFns::language($params{site}); -FixMyStreet::App->model('DB::Questionnaire')->send_questionnaires( \%params ); +FixMyStreet::DB->resultset('Questionnaire')->send_questionnaires( \%params ); diff --git a/bin/send-reports b/bin/send-reports index 3c6f26cdb..5765edbfa 100755 --- a/bin/send-reports +++ b/bin/send-reports @@ -21,9 +21,9 @@ use CGI; # XXX use CronFns; use mySociety::Config; -use FixMyStreet::App; +use FixMyStreet::DB; my $site = CronFns::site(mySociety::Config::get('BASE_URL')); CronFns::language($site); -FixMyStreet::App->model('DB::Problem')->send_reports(); +FixMyStreet::DB->resultset('Problem')->send_reports(); diff --git a/bin/update-all-reports b/bin/update-all-reports index 0627cedc2..25405e8ad 100755 --- a/bin/update-all-reports +++ b/bin/update-all-reports @@ -17,7 +17,9 @@ BEGIN { require "$d/../setenv.pl"; } -use FixMyStreet::App; +use FixMyStreet; +use FixMyStreet::DB; + use File::Path (); use File::Slurp; use JSON; @@ -32,7 +34,7 @@ if ( FixMyStreet->config('BASE_URL') =~ /zurich|zueri/ ) { $age_column = 'created'; } -my $problems = FixMyStreet::App->model("DB::Problem")->search( +my $problems = FixMyStreet::DB->resultset('Problem')->search( { state => [ FixMyStreet::DB::Result::Problem->visible_states() ], }, diff --git a/bin/zerotb/import_clinic_list.pl b/bin/zerotb/import_clinic_list.pl index 359a63925..f7bdbc092 100755 --- a/bin/zerotb/import_clinic_list.pl +++ b/bin/zerotb/import_clinic_list.pl @@ -1,7 +1,7 @@ #!/usr/bin/perl use strict; -use FixMyStreet::App; +use FixMyStreet::DB; use Text::CSV; use Getopt::Long::Descriptive; @@ -23,7 +23,7 @@ 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({ +my $clinic_user = FixMyStreet::DB->resultset('User')->find_or_create({ email => $opt->email }); if ( not $clinic_user->in_storage ) { @@ -34,7 +34,7 @@ if ( not $clinic_user->in_storage ) { my $title_row = $csv->getline( $fh ); while ( my $row = $csv->getline( $fh ) ) { - my $clinics = FixMyStreet::App->model('DB::Problem')->search({ + my $clinics = FixMyStreet::DB->resultset('Problem')->search({ title => $row->[TITLE] }); @@ -42,7 +42,7 @@ while ( my $row = $csv->getline( $fh ) ) { my $p; my $count = $clinics->count; if ( $count == 0 ) { - $p = FixMyStreet::App->model('DB::Problem')->create({ + $p = FixMyStreet::DB->resultset('Problem')->create({ title => $row->[TITLE], latitude => $lat, longitude => $long, @@ -76,14 +76,14 @@ while ( my $row = $csv->getline( $fh ) ) { $p->discard_changes; # disabling existing alerts in case email addresses have changed - my $existing = FixMyStreet::App->model('DB::Alert')->search({ + my $existing = FixMyStreet::DB->resultset('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({ + my $u = FixMyStreet::DB->resultset('User')->find_or_new({ email => $row->[EMAIL] }); $u->insert unless $u->in_storage; @@ -95,7 +95,7 @@ while ( my $row = $csv->getline( $fh ) ) { sub create_update_alert { my ( $user, $p, $verbose ) = @_; - my $a = FixMyStreet::App->model('DB::Alert')->find_or_new({ + my $a = FixMyStreet::DB->resultset('Alert')->find_or_new({ alert_type => 'new_updates', user => $user, parameter => $p->id, diff --git a/bin/zurich/convert_internal_notes_to_comments b/bin/zurich/convert_internal_notes_to_comments index ddf74851f..76db0a45b 100755 --- a/bin/zurich/convert_internal_notes_to_comments +++ b/bin/zurich/convert_internal_notes_to_comments @@ -17,15 +17,13 @@ the superuser, or one created just for this purpose? use strict; use warnings; -use FixMyStreet::App; +use FixMyStreet::DB; # Because it is not possible to determine the user that last edited the # internal_notes we need require a user to assign all the comments to. my $comment_user_id = $ARGV[0] || die "Usage: $0 id_of_user_for_comments"; -my $comment_user = FixMyStreet::App # - ->model('DB::User') # - ->find($comment_user_id) +my $comment_user = FixMyStreet::DB->resultset('User')->find($comment_user_id) || die "Could not find user with id '$comment_user_id'"; # We use now as the time for the internal note. This is not the time it was @@ -39,7 +37,7 @@ my $comment_state = 'hidden'; # Load all the comments, more reliable than trying to search on the contents of # the extra field. -my $problems = FixMyStreet::App->model('DB::Problem')->search(); +my $problems = FixMyStreet::DB->resultset('Problem')->search(); while ( my $problem = $problems->next() ) { diff --git a/bin/zurich/overdue-alert b/bin/zurich/overdue-alert index 03845dddb..0473208c5 100755 --- a/bin/zurich/overdue-alert +++ b/bin/zurich/overdue-alert @@ -19,7 +19,8 @@ BEGIN { use DateTime; use CronFns; -use FixMyStreet::App; +use FixMyStreet::Cobrand; +use FixMyStreet::DB; use FixMyStreet::Email; my ($verbose, $nomail) = CronFns::options(); @@ -29,7 +30,7 @@ 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; +my %bodies = map { $_->id => $_ } FixMyStreet::DB->resultset("Body")->all; loop_through( 'alert-moderation-overdue.txt', 0, 1, [ 'unconfirmed' ] ); loop_through( 'alert-overdue.txt', 1, 6, 'in progress' ); @@ -37,10 +38,10 @@ 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 $dtf = FixMyStreet::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( { + my $reports = FixMyStreet::DB->resultset("Problem")->search( { state => $states, created => { '<', $date_threshold }, bodies_str => { '!=', undef }, @@ -78,7 +79,7 @@ sub send_alert { } FixMyStreet::Email::send_cron( - $schema, + FixMyStreet::DB->storage->schema, { _template_ => $template, _parameters_ => $h, |