--- trunk/lib/BackupPC/SearchLib.pm 2005/08/21 17:08:55 64 +++ trunk/lib/BackupPC/SearchLib.pm 2005/08/22 00:09:59 66 @@ -105,7 +105,7 @@ FROM files INNER JOIN shares ON files.shareID=shares.ID INNER JOIN hosts ON hosts.ID = shares.hostID - INNER JOIN backups ON backups.num = files.backupNum and backups.hostID = hosts.ID + INNER JOIN backups ON backups.num = files.backupNum and backups.hostID = hosts.ID AND backups.shareID = shares.ID }; my $sql_dvd_from = qq{ @@ -169,36 +169,28 @@ my $dbh = DBI->connect($dsn, $db_user, "", { RaiseError => 1, AutoCommit => 1 } ); my $sql = q{ SELECT - hosts.ID AS hostid, + backups.hostID AS hostid, min(hosts.name) AS host, backups.num AS backupno, min(backups.type) AS type, - min(backups.date) AS date - FROM backups, shares, files, hosts + min(backups.date) AS date, + min(backups.size) AS size + FROM backups + INNER JOIN hosts ON hosts.ID = backups.hostID WHERE - backups.num = files.backupNum AND - shares.ID = files.shareID AND - backups.hostID = shares.hostID AND - hosts.ID = backups.hostID AND files.dvdid IS NULL GROUP BY - backups.hostID, backups.num, hosts.id + backups.hostID, backups.num ORDER BY min(backups.date) }; my $sth = $dbh->prepare( $sql ); my @ret; $sth->execute(); - while ( my $row = $sth->fetchrow_hashref() ) { - push(@ret, { - 'host' => $row->{'host'}, - 'hostid' => $row->{'hostid'}, - 'backupno' => $row->{'backupno'}, - 'type' => $row->{'type'}, - 'date' => $row->{'date'}, - 'age' => sprintf("%0.1f", ( (time() - $row->{'date'}) / 86400 ) ), - } - ); + while ( my $row = $sth->fetchrow_hashref() ) { + $row->{'age'} = sprintf("%0.1f", ( (time() - $row->{'date'}) / 86400 ) ); + $row->{'size'} = sprintf("%0.2f", $row->{'size'} / 1024 / 1024); + push @ret, $row; } return @ret; @@ -247,6 +239,7 @@ Type date age/days + size/MB }; @@ -278,6 +271,7 @@ '' . $backup->{'type'} . '' . '' . epoch_to_iso( $backup->{'date'} ) . '' . '' . $backup->{'age'} . '' . + '' . $backup->{'size'} . '' . ''; }