From 8ec8da0491ad89604700b3e29a227966f6d84ba1 Mon Sep 17 00:00:00 2001 From: Perl Tidy Date: Wed, 5 Dec 2018 15:38:52 -0500 Subject: no bug - reformat all the code using the new perltidy rules --- extensions/Push/lib/Backoff.pm | 82 +++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 40 deletions(-) (limited to 'extensions/Push/lib/Backoff.pm') diff --git a/extensions/Push/lib/Backoff.pm b/extensions/Push/lib/Backoff.pm index 0436cdf14..070adfc29 100644 --- a/extensions/Push/lib/Backoff.pm +++ b/extensions/Push/lib/Backoff.pm @@ -26,21 +26,21 @@ use Bugzilla::Util; # initialisation # -use constant DB_TABLE => 'push_backoff'; +use constant DB_TABLE => 'push_backoff'; use constant DB_COLUMNS => qw( - id - connector - next_attempt_ts - attempts + id + connector + next_attempt_ts + attempts ); use constant UPDATE_COLUMNS => qw( - next_attempt_ts - attempts + next_attempt_ts + attempts ); use constant VALIDATORS => { - connector => \&_check_connector, - next_attempt_ts => \&_check_next_attempt_ts, - attempts => \&_check_attempts, + connector => \&_check_connector, + next_attempt_ts => \&_check_next_attempt_ts, + attempts => \&_check_attempts, }; use constant LIST_ORDER => 'next_attempt_ts'; @@ -48,16 +48,16 @@ use constant LIST_ORDER => 'next_attempt_ts'; # accessors # -sub connector { return $_[0]->{'connector'}; } +sub connector { return $_[0]->{'connector'}; } sub next_attempt_ts { return $_[0]->{'next_attempt_ts'}; } -sub attempts { return $_[0]->{'attempts'}; } +sub attempts { return $_[0]->{'attempts'}; } sub next_attempt_time { - my ($self) = @_; - if (!exists $self->{'next_attempt_time'}) { - $self->{'next_attempt_time'} = datetime_from($self->next_attempt_ts)->epoch; - } - return $self->{'next_attempt_time'}; + my ($self) = @_; + if (!exists $self->{'next_attempt_time'}) { + $self->{'next_attempt_time'} = datetime_from($self->next_attempt_ts)->epoch; + } + return $self->{'next_attempt_time'}; } # @@ -65,25 +65,26 @@ sub next_attempt_time { # sub reset { - my ($self) = @_; - $self->{next_attempt_ts} = Bugzilla->dbh->selectrow_array('SELECT NOW()'); - $self->{attempts} = 0; - INFO( sprintf 'resetting backoff for %s', $self->connector ); + my ($self) = @_; + $self->{next_attempt_ts} = Bugzilla->dbh->selectrow_array('SELECT NOW()'); + $self->{attempts} = 0; + INFO(sprintf 'resetting backoff for %s', $self->connector); } sub inc { - my ($self) = @_; - my $dbh = Bugzilla->dbh; - - my $attempts = $self->attempts + 1; - my $seconds = $attempts <= 4 ? 5 ** $attempts : 15 * 60; - my ($date) = $dbh->selectrow_array("SELECT " . $dbh->sql_date_math('NOW()', '+', $seconds, 'SECOND')); - - $self->{next_attempt_ts} = $date; - $self->{attempts} = $attempts; - INFO( - sprintf 'setting next attempt for %s to %s (attempt %s)', $self->connector, $date, $attempts - ); + my ($self) = @_; + my $dbh = Bugzilla->dbh; + + my $attempts = $self->attempts + 1; + my $seconds = $attempts <= 4 ? 5**$attempts : 15 * 60; + my ($date) + = $dbh->selectrow_array( + "SELECT " . $dbh->sql_date_math('NOW()', '+', $seconds, 'SECOND')); + + $self->{next_attempt_ts} = $date; + $self->{attempts} = $attempts; + INFO(sprintf 'setting next attempt for %s to %s (attempt %s)', + $self->connector, $date, $attempts); } # @@ -91,19 +92,20 @@ sub inc { # sub _check_connector { - my ($invocant, $value) = @_; - Bugzilla->push_ext->connectors->exists($value) || ThrowCodeError('push_invalid_connector'); - return $value; + my ($invocant, $value) = @_; + Bugzilla->push_ext->connectors->exists($value) + || ThrowCodeError('push_invalid_connector'); + return $value; } sub _check_next_attempt_ts { - my ($invocant, $value) = @_; - return $value || Bugzilla->dbh->selectrow_array('SELECT NOW()'); + my ($invocant, $value) = @_; + return $value || Bugzilla->dbh->selectrow_array('SELECT NOW()'); } sub _check_attempts { - my ($invocant, $value) = @_; - return $value || 0; + my ($invocant, $value) = @_; + return $value || 0; } 1; -- cgit v1.2.3-24-g4f1b