aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/SendReport.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2013-05-02 18:48:39 +0100
committerMatthew Somerville <matthew@mysociety.org>2013-05-02 20:48:05 +0100
commit9b6a6fd63daacf67cddb4f5ab7bbcd0375082696 (patch)
tree2f832a82aac5ce6050090a3d250b7bec93274902 /perllib/FixMyStreet/SendReport.pm
parentc4b3f85594e91c772011dffef2da2498ee5c8a5e (diff)
Consolidate sending backoff for different types of sender.
Diffstat (limited to 'perllib/FixMyStreet/SendReport.pm')
-rw-r--r--perllib/FixMyStreet/SendReport.pm13
1 files changed, 11 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/SendReport.pm b/perllib/FixMyStreet/SendReport.pm
index f8901c6f8..5087c7ead 100644
--- a/perllib/FixMyStreet/SendReport.pm
+++ b/perllib/FixMyStreet/SendReport.pm
@@ -12,13 +12,22 @@ has 'bodies' => ( is => 'rw', isa => 'ArrayRef', default => sub { [] } );
has 'to' => ( is => 'rw', isa => 'ArrayRef', default => sub { [] } );
has 'success' => ( is => 'rw', isa => 'Bool', default => 0 );
has 'error' => ( is => 'rw', isa => 'Str', default => '' );
-has 'skipped' => ( 'is' => 'rw', isa => 'Str', default => '' );
has 'unconfirmed_counts' => ( 'is' => 'rw', isa => 'HashRef', default => sub { {} } );
has 'unconfirmed_notes' => ( 'is' => 'rw', isa => 'HashRef', default => sub { {} } );
sub should_skip {
- return 0;
+ my $self = shift;
+ my $row = shift;
+
+ return 0 unless $row->send_fail_count;
+
+ my $tz = DateTime::TimeZone->new( name => 'local' );
+ my $now = DateTime->now( time_zone => $tz );
+ my $diff = $now - $row->send_fail_timestamp;
+
+ my $backoff = $row->send_fail_count > 1 ? 30 : 5;
+ return $diff->in_units( 'minutes' ) < $backoff;
}
sub get_senders {