aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/DB
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2015-08-13 12:21:20 +0100
committerMatthew Somerville <matthew@mysociety.org>2015-08-13 13:38:14 +0100
commitef3a3a789e8f91b62dc562ff69781dc0daa80871 (patch)
tree6045ce7399229bfcb2eca4090f1707d6fc79830b /perllib/FixMyStreet/DB
parent864fcb6a81b17ec6324598973ff29dd734a7baf8 (diff)
Remove ms_current_timestamp() override function.
This override is not used anywhere, it dates from a very old long-gone test script, and causes issues with database query planning.
Diffstat (limited to 'perllib/FixMyStreet/DB')
-rw-r--r--perllib/FixMyStreet/DB/Result/AdminLog.pm2
-rw-r--r--perllib/FixMyStreet/DB/Result/Alert.pm4
-rw-r--r--perllib/FixMyStreet/DB/Result/AlertSent.pm2
-rw-r--r--perllib/FixMyStreet/DB/Result/Comment.pm4
-rw-r--r--perllib/FixMyStreet/DB/Result/ModerationOriginalData.pm2
-rw-r--r--perllib/FixMyStreet/DB/Result/Problem.pm12
-rw-r--r--perllib/FixMyStreet/DB/Result/Token.pm7
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Alert.pm4
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/AlertType.pm4
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Comment.pm2
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Problem.pm10
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Questionnaire.pm10
12 files changed, 31 insertions, 32 deletions
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 },
},