diff options
Diffstat (limited to 'perllib/FixMyStreet')
19 files changed, 57 insertions, 58 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index 6145a6eb0..44b898743 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -359,7 +359,7 @@ sub update_contacts : Private { $contact->deleted( $c->get_param('deleted') ? 1 : 0 ); $contact->non_public( $c->get_param('non_public') ? 1 : 0 ); $contact->note( $c->get_param('note') ); - $contact->whenedited( \'ms_current_timestamp()' ); + $contact->whenedited( \'current_timestamp' ); $contact->editor( $editor ); $contact->endpoint( $c->get_param('endpoint') ); $contact->jurisdiction( $c->get_param('jurisdiction') ); @@ -395,7 +395,7 @@ sub update_contacts : Private { $contacts->update( { confirmed => 1, - whenedited => \'ms_current_timestamp()', + whenedited => \'current_timestamp', note => 'Confirmed', editor => $editor, } @@ -707,7 +707,7 @@ sub report_edit : Path('report_edit') : Args(1) { } elsif ( $c->get_param('mark_sent') ) { $c->forward('check_token'); - $problem->whensent(\'ms_current_timestamp()'); + $problem->whensent(\'current_timestamp'); $problem->update(); $c->stash->{status_message} = '<p><em>' . _('That problem has been marked as sent.') . '</em></p>'; $c->forward( 'log_edit', [ $id, 'problem', 'marked sent' ] ); @@ -787,14 +787,14 @@ sub report_edit : Path('report_edit') : Args(1) { } if ( $problem->is_visible() and $old_state eq 'unconfirmed' ) { - $problem->confirmed( \'ms_current_timestamp()' ); + $problem->confirmed( \'current_timestamp' ); } if ($done) { $problem->discard_changes; } else { - $problem->lastupdate( \'ms_current_timestamp()' ) if $edited || $new_state ne $old_state; + $problem->lastupdate( \'current_timestamp' ) if $edited || $new_state ne $old_state; $problem->update; if ( $new_state ne $old_state ) { @@ -943,10 +943,10 @@ sub update_edit : Path('update_edit') : Args(1) { } if ( $new_state eq 'confirmed' and $old_state eq 'unconfirmed' ) { - $update->confirmed( \'ms_current_timestamp()' ); + $update->confirmed( \'current_timestamp' ); if ( $update->problem_state && $update->created > $update->problem->lastupdate ) { $update->problem->state( $update->problem_state ); - $update->problem->lastupdate( \'ms_current_timestamp()' ); + $update->problem->lastupdate( \'current_timestamp' ); $update->problem->update; } } diff --git a/perllib/FixMyStreet/App/Controller/Questionnaire.pm b/perllib/FixMyStreet/App/Controller/Questionnaire.pm index f9a08e408..035cab3a6 100755 --- a/perllib/FixMyStreet/App/Controller/Questionnaire.pm +++ b/perllib/FixMyStreet/App/Controller/Questionnaire.pm @@ -142,8 +142,8 @@ sub submit_creator_fixed : Private { $questionnaire->ever_reported( $c->stash->{reported} eq 'Yes' ? 1 : 0 ); $questionnaire->old_state( $old_state ); - $questionnaire->whensent( \'ms_current_timestamp()' ); - $questionnaire->whenanswered( \'ms_current_timestamp()' ); + $questionnaire->whensent( \'current_timestamp' ); + $questionnaire->whenanswered( \'current_timestamp' ); $questionnaire->insert; } @@ -173,13 +173,13 @@ sub submit_standard : Private { # Record state change, if there was one if ( $new_state ) { $problem->state( $new_state ); - $problem->lastupdate( \'ms_current_timestamp()' ); + $problem->lastupdate( \'current_timestamp' ); } # If it's not fixed and they say it's still not been fixed, record time update if ( $c->stash->{been_fixed} eq 'No' && FixMyStreet::DB::Result::Problem->open_states->{$old_state} ) { - $problem->lastupdate( \'ms_current_timestamp()' ); + $problem->lastupdate( \'current_timestamp' ); } # Record questionnaire response @@ -189,7 +189,7 @@ sub submit_standard : Private { my $q = $c->stash->{questionnaire}; $q->update( { - whenanswered => \'ms_current_timestamp()', + whenanswered => \'current_timestamp', ever_reported => $reported, old_state => $old_state, new_state => $c->stash->{been_fixed} eq 'Unknown' ? 'unknown' : ($new_state || $old_state), @@ -210,7 +210,7 @@ sub submit_standard : Private { lang => $c->stash->{lang_code}, cobrand => $c->cobrand->moniker, cobrand_data => '', - confirmed => \'ms_current_timestamp()', + confirmed => \'current_timestamp', anonymous => $problem->anonymous, } ); diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index 7b001ee4c..315a5436c 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -242,7 +242,7 @@ sub delete :Local :Args(1) { return $c->res->redirect($uri) unless $p->bodies->{$body->id}; $p->state('hidden'); - $p->lastupdate( \'ms_current_timestamp()' ); + $p->lastupdate( \'current_timestamp' ); $p->update; $c->model('DB::AdminLog')->create( { diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm index 17aec2113..445723fec 100644 --- a/perllib/FixMyStreet/App/Controller/Report/Update.pm +++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm @@ -80,7 +80,7 @@ sub update_problem : Private { $problem->interest_count( \'interest_count + 1' ); } - $problem->lastupdate( \'ms_current_timestamp()' ); + $problem->lastupdate( \'current_timestamp' ); $problem->update; $c->stash->{problem_id} = $problem->id; diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm index 6b0d516a6..4582843bd 100644 --- a/perllib/FixMyStreet/App/Controller/Reports.pm +++ b/perllib/FixMyStreet/App/Controller/Reports.pm @@ -396,20 +396,20 @@ sub load_and_group_problems : Private { my $not_open = [ FixMyStreet::DB::Result::Problem::fixed_states(), FixMyStreet::DB::Result::Problem::closed_states() ]; if ( $type eq 'new' ) { - $where->{confirmed} = { '>', \"ms_current_timestamp() - INTERVAL '4 week'" }; + $where->{confirmed} = { '>', \"current_timestamp - INTERVAL '4 week'" }; $where->{state} = { 'IN', [ FixMyStreet::DB::Result::Problem::open_states() ] }; } elsif ( $type eq 'older' ) { - $where->{confirmed} = { '<', \"ms_current_timestamp() - INTERVAL '4 week'" }; - $where->{lastupdate} = { '>', \"ms_current_timestamp() - INTERVAL '8 week'" }; + $where->{confirmed} = { '<', \"current_timestamp - INTERVAL '4 week'" }; + $where->{lastupdate} = { '>', \"current_timestamp - INTERVAL '8 week'" }; $where->{state} = { 'IN', [ FixMyStreet::DB::Result::Problem::open_states() ] }; } elsif ( $type eq 'unknown' ) { - $where->{lastupdate} = { '<', \"ms_current_timestamp() - INTERVAL '8 week'" }; + $where->{lastupdate} = { '<', \"current_timestamp - INTERVAL '8 week'" }; $where->{state} = { 'IN', [ FixMyStreet::DB::Result::Problem::open_states() ] }; } elsif ( $type eq 'fixed' ) { - $where->{lastupdate} = { '>', \"ms_current_timestamp() - INTERVAL '8 week'" }; + $where->{lastupdate} = { '>', \"current_timestamp - INTERVAL '8 week'" }; $where->{state} = $not_open; } elsif ( $type eq 'older_fixed' ) { - $where->{lastupdate} = { '<', \"ms_current_timestamp() - INTERVAL '8 week'" }; + $where->{lastupdate} = { '<', \"current_timestamp - INTERVAL '8 week'" }; $where->{state} = $not_open; } diff --git a/perllib/FixMyStreet/App/Controller/Tokens.pm b/perllib/FixMyStreet/App/Controller/Tokens.pm index 21c269502..ba15162ce 100644 --- a/perllib/FixMyStreet/App/Controller/Tokens.pm +++ b/perllib/FixMyStreet/App/Controller/Tokens.pm @@ -58,7 +58,7 @@ sub confirm_problem : Path('/P') { # check that this email or domain are not the cause of abuse. If so hide it. if ( $problem->is_from_abuser ) { $problem->update( - { state => 'hidden', lastupdate => \'ms_current_timestamp()' } ); + { state => 'hidden', lastupdate => \'current_timestamp' } ); $c->stash->{template} = 'tokens/abuse.html'; return; } @@ -68,7 +68,7 @@ sub confirm_problem : Path('/P') { if ($c->cobrand->moniker eq 'zurich') { $problem->set_extra_metadata( email_confirmed => 1 ); $problem->update( { - confirmed => \'ms_current_timestamp()', + confirmed => \'current_timestamp', } ); if ( $data->{name} || $data->{password} ) { @@ -90,8 +90,8 @@ sub confirm_problem : Path('/P') { $problem->update( { state => 'confirmed', - confirmed => \'ms_current_timestamp()', - lastupdate => \'ms_current_timestamp()', + confirmed => \'current_timestamp', + lastupdate => \'current_timestamp', } ); diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm index c64fe1177..9ed65c5f5 100644 --- a/perllib/FixMyStreet/Cobrand/Zurich.pm +++ b/perllib/FixMyStreet/Cobrand/Zurich.pm @@ -549,7 +549,7 @@ sub admin_report_edit { } } - $problem->lastupdate( \'ms_current_timestamp()' ); + $problem->lastupdate( \'current_timestamp' ); $problem->update; $c->stash->{status_message} = diff --git a/perllib/FixMyStreet/DB/Result/AdminLog.pm b/perllib/FixMyStreet/DB/Result/AdminLog.pm index 41bc3100a..d26eba7f5 100644 --- a/perllib/FixMyStreet/DB/Result/AdminLog.pm +++ b/perllib/FixMyStreet/DB/Result/AdminLog.pm @@ -29,7 +29,7 @@ __PACKAGE__->add_columns( "whenedited", { data_type => "timestamp", - default_value => \"ms_current_timestamp()", + default_value => \"current_timestamp", is_nullable => 0, }, "user_id", diff --git a/perllib/FixMyStreet/DB/Result/Alert.pm b/perllib/FixMyStreet/DB/Result/Alert.pm index c64cb2ff4..21010064b 100644 --- a/perllib/FixMyStreet/DB/Result/Alert.pm +++ b/perllib/FixMyStreet/DB/Result/Alert.pm @@ -37,7 +37,7 @@ __PACKAGE__->add_columns( "whensubscribed", { data_type => "timestamp", - default_value => \"ms_current_timestamp()", + default_value => \"current_timestamp", is_nullable => 0, }, "whendisabled", @@ -106,7 +106,7 @@ sub confirm { sub disable { my $self = shift; - $self->whendisabled( \'ms_current_timestamp()' ); + $self->whendisabled( \'current_timestamp' ); $self->update; return 1; diff --git a/perllib/FixMyStreet/DB/Result/AlertSent.pm b/perllib/FixMyStreet/DB/Result/AlertSent.pm index 422e010a9..154f8b42e 100644 --- a/perllib/FixMyStreet/DB/Result/AlertSent.pm +++ b/perllib/FixMyStreet/DB/Result/AlertSent.pm @@ -18,7 +18,7 @@ __PACKAGE__->add_columns( "whenqueued", { data_type => "timestamp", - default_value => \"ms_current_timestamp()", + default_value => \"current_timestamp", is_nullable => 0, }, ); diff --git a/perllib/FixMyStreet/DB/Result/Comment.pm b/perllib/FixMyStreet/DB/Result/Comment.pm index 836462ed5..0c1072a78 100644 --- a/perllib/FixMyStreet/DB/Result/Comment.pm +++ b/perllib/FixMyStreet/DB/Result/Comment.pm @@ -31,7 +31,7 @@ __PACKAGE__->add_columns( "created", { data_type => "timestamp", - default_value => \"ms_current_timestamp()", + default_value => \"current_timestamp", is_nullable => 0, }, "confirmed", @@ -144,7 +144,7 @@ sub confirm { my $self = shift; $self->state( 'confirmed' ); - $self->confirmed( \'ms_current_timestamp()' ); + $self->confirmed( \'current_timestamp' ); } =head2 get_photo_params diff --git a/perllib/FixMyStreet/DB/Result/ModerationOriginalData.pm b/perllib/FixMyStreet/DB/Result/ModerationOriginalData.pm index 08d03f94b..13ecf82cd 100644 --- a/perllib/FixMyStreet/DB/Result/ModerationOriginalData.pm +++ b/perllib/FixMyStreet/DB/Result/ModerationOriginalData.pm @@ -33,7 +33,7 @@ __PACKAGE__->add_columns( "created", { data_type => "timestamp", - default_value => \"ms_current_timestamp()", + default_value => \"current_timestamp", is_nullable => 0, }, ); diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index bed2f160a..caf748f1e 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -53,7 +53,7 @@ __PACKAGE__->add_columns( "created", { data_type => "timestamp", - default_value => \"ms_current_timestamp()", + default_value => \"current_timestamp", is_nullable => 0, }, "confirmed", @@ -71,7 +71,7 @@ __PACKAGE__->add_columns( "lastupdate", { data_type => "timestamp", - default_value => \"ms_current_timestamp()", + default_value => \"current_timestamp", is_nullable => 0, }, "whensent", @@ -441,7 +441,7 @@ sub confirm { return if $self->state eq 'confirmed'; $self->state('confirmed'); - $self->confirmed( \'ms_current_timestamp()' ); + $self->confirmed( \'current_timestamp' ); return 1; } @@ -735,8 +735,8 @@ sub update_from_open311_service_request { { problem_id => $self->id, state => 'confirmed', - created => $updated || \'ms_current_timestamp()', - confirmed => \'ms_current_timestamp()', + created => $updated || \'current_timestamp', + confirmed => \'current_timestamp', text => $status_notes, mark_open => 0, mark_fixed => 0, @@ -789,7 +789,7 @@ sub update_send_failed { $self->update( { send_fail_count => $self->send_fail_count + 1, - send_fail_timestamp => \'ms_current_timestamp()', + send_fail_timestamp => \'current_timestamp', send_fail_reason => $msg } ); } diff --git a/perllib/FixMyStreet/DB/Result/Token.pm b/perllib/FixMyStreet/DB/Result/Token.pm index 0156af137..90715bdd9 100644 --- a/perllib/FixMyStreet/DB/Result/Token.pm +++ b/perllib/FixMyStreet/DB/Result/Token.pm @@ -20,7 +20,7 @@ __PACKAGE__->add_columns( "created", { data_type => "timestamp", - default_value => \"ms_current_timestamp()", + default_value => \"current_timestamp", is_nullable => 0, }, ); @@ -42,8 +42,7 @@ Representation of mySociety::AuthToken in the DBIx::Class world. 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 -ms_current_timestamp. +'created' timestamp is achieved using the database function current_timestamp. =cut @@ -55,7 +54,7 @@ sub new { my ( $class, $attrs ) = @_; $attrs->{token} ||= mySociety::AuthToken::random_token(); - $attrs->{created} ||= \'ms_current_timestamp()'; + $attrs->{created} ||= \'current_timestamp'; my $new = $class->next::method($attrs); return $new; diff --git a/perllib/FixMyStreet/DB/ResultSet/Alert.pm b/perllib/FixMyStreet/DB/ResultSet/Alert.pm index 5848265f1..bb1c61141 100644 --- a/perllib/FixMyStreet/DB/ResultSet/Alert.pm +++ b/perllib/FixMyStreet/DB/ResultSet/Alert.pm @@ -14,7 +14,7 @@ sub timeline_created { return $rs->search( { - whensubscribed => { '>=', \"ms_current_timestamp()-'7 days'::interval" }, + whensubscribed => { '>=', \"current_timestamp-'7 days'::interval" }, confirmed => 1, %{ $restriction }, }, @@ -29,7 +29,7 @@ sub timeline_disabled { return $rs->search( { - whendisabled => { '>=', \"ms_current_timestamp()-'7 days'::interval" }, + whendisabled => { '>=', \"current_timestamp-'7 days'::interval" }, %{ $restriction }, }, ); diff --git a/perllib/FixMyStreet/DB/ResultSet/AlertType.pm b/perllib/FixMyStreet/DB/ResultSet/AlertType.pm index 0b430008a..9bb1e81fe 100644 --- a/perllib/FixMyStreet/DB/ResultSet/AlertType.pm +++ b/perllib/FixMyStreet/DB/ResultSet/AlertType.pm @@ -41,7 +41,7 @@ sub email_alerts ($) { } $query .= " where alert_type='$ref' and whendisabled is null and $item_table.confirmed >= whensubscribed - and $item_table.confirmed >= ms_current_timestamp() - '7 days'::interval + and $item_table.confirmed >= current_timestamp - '7 days'::interval and (select whenqueued from alert_sent where alert_sent.alert_id = alert.id and alert_sent.parameter::integer = $item_table.id) is null and $item_table.user_id <> alert.user_id and " . $alert_type->item_where . " @@ -184,7 +184,7 @@ sub email_alerts ($) { and problem.user_id = users.id and problem.state in ($states) and problem.non_public = 'f' - and problem.confirmed >= ? and problem.confirmed >= ms_current_timestamp() - '7 days'::interval + and problem.confirmed >= ? and problem.confirmed >= current_timestamp - '7 days'::interval and (select whenqueued from alert_sent where alert_sent.alert_id = ? and alert_sent.parameter::integer = problem.id) is null and users.email <> ? order by confirmed desc"; diff --git a/perllib/FixMyStreet/DB/ResultSet/Comment.pm b/perllib/FixMyStreet/DB/ResultSet/Comment.pm index 70f8027aa..abdc46868 100644 --- a/perllib/FixMyStreet/DB/ResultSet/Comment.pm +++ b/perllib/FixMyStreet/DB/ResultSet/Comment.pm @@ -15,7 +15,7 @@ sub timeline { return $rs->search( { state => 'confirmed', - created => { '>=', \"ms_current_timestamp()-'7 days'::interval" }, + created => { '>=', \"current_timestamp-'7 days'::interval" }, %{ $restriction }, }, { diff --git a/perllib/FixMyStreet/DB/ResultSet/Problem.pm b/perllib/FixMyStreet/DB/ResultSet/Problem.pm index 7885c28b3..611c1582e 100644 --- a/perllib/FixMyStreet/DB/ResultSet/Problem.pm +++ b/perllib/FixMyStreet/DB/ResultSet/Problem.pm @@ -168,9 +168,9 @@ sub timeline { return $rs->search( { -or => { - created => { '>=', \"ms_current_timestamp()-'7 days'::interval" }, - confirmed => { '>=', \"ms_current_timestamp()-'7 days'::interval" }, - whensent => { '>=', \"ms_current_timestamp()-'7 days'::interval" }, + created => { '>=', \"current_timestamp-'7 days'::interval" }, + confirmed => { '>=', \"current_timestamp-'7 days'::interval" }, + whensent => { '>=', \"current_timestamp-'7 days'::interval" }, } }, { @@ -433,8 +433,8 @@ sub send_reports { unless ($result) { $row->update( { - whensent => \'ms_current_timestamp()', - lastupdate => \'ms_current_timestamp()', + whensent => \'current_timestamp', + lastupdate => \'current_timestamp', } ); if ( $cobrand->report_sent_confirmation_email && !$h{anonymous_report}) { _send_report_sent_email( $row, \%h, $nomail, $cobrand ); diff --git a/perllib/FixMyStreet/DB/ResultSet/Questionnaire.pm b/perllib/FixMyStreet/DB/ResultSet/Questionnaire.pm index 63a91697d..1b89b2e65 100644 --- a/perllib/FixMyStreet/DB/ResultSet/Questionnaire.pm +++ b/perllib/FixMyStreet/DB/ResultSet/Questionnaire.pm @@ -22,7 +22,7 @@ sub send_questionnaires_period { whensent => [ '-and', { '!=', undef }, - { '<', \"ms_current_timestamp() - '$period'::interval" }, + { '<', \"current_timestamp - '$period'::interval" }, ], send_questionnaire => 1, }; @@ -34,7 +34,7 @@ sub send_questionnaires_period { } else { $q_params->{'-or'} = [ '(select max(whensent) from questionnaire where me.id=problem_id)' => undef, - '(select max(whenanswered) from questionnaire where me.id=problem_id)' => { '<', \"ms_current_timestamp() - '$period'::interval" } + '(select max(whenanswered) from questionnaire where me.id=problem_id)' => { '<', \"current_timestamp - '$period'::interval" } ]; } @@ -70,7 +70,7 @@ sub send_questionnaires_period { my $questionnaire = FixMyStreet::App->model('DB::Questionnaire')->create( { problem_id => $row->id, - whensent => \'ms_current_timestamp()', + whensent => \'current_timestamp', } ); # We won't send another questionnaire unless they ask for it (or it was @@ -120,8 +120,8 @@ sub timeline { return $rs->search( { -or => { - whenanswered => { '>=', \"ms_current_timestamp()-'7 days'::interval" }, - 'me.whensent' => { '>=', \"ms_current_timestamp()-'7 days'::interval" }, + whenanswered => { '>=', \"current_timestamp-'7 days'::interval" }, + 'me.whensent' => { '>=', \"current_timestamp-'7 days'::interval" }, }, %{ $restriction }, }, |