aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/SendReport.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/SendReport.pm')
-rw-r--r--perllib/FixMyStreet/SendReport.pm28
1 files changed, 19 insertions, 9 deletions
diff --git a/perllib/FixMyStreet/SendReport.pm b/perllib/FixMyStreet/SendReport.pm
index 9ba507862..5087c7ead 100644
--- a/perllib/FixMyStreet/SendReport.pm
+++ b/perllib/FixMyStreet/SendReport.pm
@@ -7,17 +7,27 @@ use Module::Pluggable
search_path => __PACKAGE__,
require => 1;
-has 'councils' => ( is => 'rw', isa => 'HashRef', default => sub { {} } );
+has 'body_config' => ( is => 'rw', isa => 'HashRef', default => sub { {} } );
+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 {
@@ -31,18 +41,18 @@ sub get_senders {
sub reset {
my $self = shift;
- $self->councils( {} );
+ $self->bodies( [] );
+ $self->body_config( {} );
$self->to( [] );
}
-sub add_council {
+sub add_body {
my $self = shift;
- my $council = shift;
- my $info = shift;
+ my $body = shift;
my $config = shift;
- $self->councils->{ $council } = { info => $info, config => $config };
+ push @{$self->bodies}, $body;
+ $self->body_config->{ $body->id } = $config;
}
-
1;