X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=lib%2FBackupPC%2FSearch.pm;h=3783c554f6af8c0ed2875eeb97138def66ddd6be;hb=refs%2Fheads%2Fhospira;hp=ee982fffb4201d5f71a5c6660e54f95ee509322a;hpb=37393374870be74815cbe9e42c1d284ff03945c7;p=BackupPC.git diff --git a/lib/BackupPC/Search.pm b/lib/BackupPC/Search.pm index ee982ff..3783c55 100644 --- a/lib/BackupPC/Search.pm +++ b/lib/BackupPC/Search.pm @@ -45,7 +45,7 @@ sub get_dbh { return $dbh; } -sub getUnits() { +sub getShares { my @ret; my $dbh = get_dbh(); @@ -61,6 +61,9 @@ sub getUnits() { push @ret, { 'id' => '', 'share' => '-'}; # dummy any while ( my $row = $sth->fetchrow_hashref() ) { + if ( my $hide = $Conf{SearchHideShare} ) { + next if $row->{share} =~ m/$hide/; + } push @ret, $row; } return @ret; @@ -101,6 +104,12 @@ sub dates_from_form($) { $dt -= DateTime::Duration->new( days => 1 ); } + if ( $suffix eq 'to' ) { + # to end of day + $dt += DateTime::Duration->new( days => 1 ); + $dt -= DateTime::Duration->new( seconds => 1 ); + } + print STDERR "mk_epoch_date($name,$suffix) [$yyyy-$mm-$dd] = " . $dt->ymd . " " . $dt->hms . "\n"; return $dt->epoch || 'NULL'; } @@ -354,6 +363,45 @@ sub getGzipSize($$) ); } +sub host_backup_nums { + my $host = shift; + my $sth = get_dbh->prepare(qq{ + select + hosts.name as host, -- FIXME for debug + backups.num as num, + inc_size, + size, + inc_deleted + from backups + join hosts on hosts.id = hostid + where hosts.name = ? + }); + $sth->execute($host); + # and inc_size < 0 and size > 0 and not inc_deleted + + my $all_backup_numbers; + # pre-seed with on disk backups + $all_backup_numbers->{ $_->{num} }++ foreach $bpc->BackupInfoRead($host); + + while( my $row = $sth->fetchrow_hashref ) { +warn "# row ",dump $row; + $all_backup_numbers->{ $row->{num} } = + $row->{inc_deleted} ? 0 : + $row->{size} == 0 ? 0 : + $row->{inc_size}!= 0 ? 0 : + $row->{size} > 0 ? 1 : + 0; + } + +warn "# host $host all_backup_numbers = ",dump($all_backup_numbers); + my @backup_nums = + sort { $a <=> $b } + grep { $all_backup_numbers->{$_} } + keys %$all_backup_numbers; + + return @backup_nums; +} + sub getBackupsNotBurned($) {