diff --git a/Changes b/Changes index 16a1a4d8..1a375692 100644 --- a/Changes +++ b/Changes @@ -8,6 +8,7 @@ [BUG FIXES] * Change name of d3 javascript file to force browser reload + * Make expire_nodes and expire_nodes_archive behave correctly 2.038001 - 2018-01-02 diff --git a/lib/App/Netdisco/DB/ResultSet/Node.pm b/lib/App/Netdisco/DB/ResultSet/Node.pm index 5c7e1920..a0e48826 100644 --- a/lib/App/Netdisco/DB/ResultSet/Node.pm +++ b/lib/App/Netdisco/DB/ResultSet/Node.pm @@ -109,6 +109,18 @@ sub delete { return 0E0; } else { + foreach my $set (qw/ + NodeMonitor + NodeWireless + /) { + $schema->resultset($set)->search( + { mac => { '-in' => $nodes->as_query }}, + )->delete; + } + + # now let DBIC do its thing + my @retval = ($self->next::method()); + # for node_ip and node_nbt *only* delete if there are no longer # any active nodes referencing the IP or NBT (hence 2nd IN clause). foreach my $set (qw/ @@ -132,17 +144,7 @@ sub delete { })->delete; } - foreach my $set (qw/ - NodeMonitor - NodeWireless - /) { - $schema->resultset($set)->search( - { mac => { '-in' => $nodes->as_query }}, - )->delete; - } - - # now let DBIC do its thing - return $self->next::method(); + return (wantarray ? @retval : $retval[0]); } }