skipover now implicit from deferrals/actionset; fix sql where logic with better correlation

This commit is contained in:
Oliver Gorwits
2017-05-23 17:27:43 +01:00
parent b51edbccd2
commit 4550b8a84c
5 changed files with 40 additions and 17 deletions

View File

@@ -14,11 +14,9 @@ __PACKAGE__->add_columns(
"device",
{ data_type => "inet", is_nullable => 0 },
"actionset",
{ data_type => "text[]", is_nullable => 0 },
{ data_type => "text[]", is_nullable => 0, default_value => '{}' },
"deferrals",
{ data_type => "integer", is_nullable => 1, default_value => '0' },
"skipover",
{ data_type => "boolean", is_nullable => 1, default_value => \'false' },
);
__PACKAGE__->set_primary_key("backend", "device");
@@ -38,7 +36,7 @@ There is a race in the update, but this is not worrying for now.
sub increment_deferrals {
my $row = shift;
return unless $row->in_storage;
return $row->update({ deferrals => ($row->deferrals + 1) });
return $row->update({ deferrals => (($row->deferrals || 0) + 1) });
}
=head2 add_to_actionset
@@ -49,7 +47,7 @@ sub add_to_actionset {
my ($row, @badactions) = @_;
return unless $row->in_storage;
return unless scalar @badactions;
return $row->update({ skipover => \'true', actionset =>
return $row->update({ actionset =>
[ sort (List::MoreUtils::uniq( @{ $row->actionset || [] }, @badactions )) ]
});
}