increment deferrals field when job is deferred
This commit is contained in:
		| @@ -18,6 +18,25 @@ __PACKAGE__->add_columns( | ||||
|   "skipover", | ||||
|   { data_type => "boolean", is_nullable => 1, default_value => \'false' }, | ||||
| ); | ||||
|  | ||||
| __PACKAGE__->set_primary_key("backend", "device", "action"); | ||||
|  | ||||
| __PACKAGE__->add_unique_constraint( | ||||
|   device_skip_pkey => [qw/backend device action/]); | ||||
|  | ||||
| =head1 METHODS | ||||
|  | ||||
| =head2 increment_deferrals | ||||
|  | ||||
| Increments the C<deferrals> field in the row, only if the row is in storage. | ||||
| There is a race in the update, but this is not worrying for now. | ||||
|  | ||||
| =cut | ||||
|  | ||||
| sub increment_deferrals { | ||||
|   my $row = shift; | ||||
|   return unless $row->in_storage; | ||||
|   return $row->update({ deferrals => ($row->deferrals + 1) }); | ||||
| } | ||||
|  | ||||
| 1; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user