--- trunk/lib/BackupPC/SearchLib.pm 2005/08/20 17:19:48 53 +++ trunk/lib/BackupPC/SearchLib.pm 2005/08/21 14:26:23 58 @@ -7,6 +7,7 @@ use DBI; use DateTime; use vars qw(%In $MyURL); +use Time::HiRes qw/time/; my $on_page = 100; my $pager_pages = 10; @@ -98,6 +99,9 @@ files.date AS date, files.type AS filetype, files.size AS size, + }; + + my $sql_dvd_cols = qq{ dvds.name AS dvd }; @@ -106,6 +110,9 @@ 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 + }; + + my $sql_dvd_from = qq{ LEFT JOIN dvds ON dvds.ID = files.dvdid }; @@ -126,7 +133,7 @@ my ($results) = $sth->fetchrow_array(); - $sth = $dbh->prepare(qq{ select $sql_cols $sql_from $sql_where $sql_order }); + $sth = $dbh->prepare(qq{ select $sql_cols $sql_dvd_cols $sql_from $sql_dvd_from $sql_where $sql_order }); $sth->execute( $offset ); my @ret; @@ -172,6 +179,7 @@ files.dvdid IS NULL GROUP BY backups.hostID, backups.num, hosts.id + ORDER BY min(backups.date) }; my $sth = $dbh->prepare( $sql ); my @ret; @@ -179,11 +187,12 @@ while ( my $row = $sth->fetchrow_hashref() ) { push(@ret, { - 'host' => $row->{'host'}, - 'hostid' => $row->{'hostid'}, - 'backupno' => $row->{'backupno'}, - 'type' => $row->{'type'}, - 'date' => $row->{'date'} + 'host' => $row->{'host'}, + 'hostid' => $row->{'hostid'}, + 'backupno' => $row->{'backupno'}, + 'type' => $row->{'type'}, + 'date' => $row->{'date'}, + 'age' => sprintf("%0.1f", ( (time() - $row->{'date'}) / 86400 ) ), } ); } @@ -228,15 +237,24 @@ if ($addForm) { $retHTML .= ""; } - $retHTML .= qq{HostBackup noTypedate}; + $retHTML .= qq{ + Host + Backup no + Type + date + age/days + + }; my @backups = getBackupsNotBurned(); my $backup; if ($addForm) { - $retHTML .= qq{ + $retHTML .= qq{ + - }; + + }; } foreach $backup(@backups) { @@ -245,16 +263,17 @@ $retHTML .= ""; if ($addForm) { - $retHTML .= qq{{'backupno'} . - qq{" value="} . $backup->{'hostid'}."_".$backup->{'backupno'} . - qq{">}; + $retHTML .= ''; } $retHTML .= '' . $backup->{'host'} . '' . '' . $backup->{'backupno'} . '' . '' . $backup->{'type'} . '' . - '' . epoch_to_iso( $backup->{'date'} ) . '' . + '' . epoch_to_iso( $backup->{'date'} ) . '' . + '' . $backup->{'age'} . '' . ''; } @@ -277,12 +296,17 @@ $retHTML .= qq{}; } + my $start_t = time(); + my ($results, $files) = getFiles($where, $offset); + my $dur_t = time() - $start_t; + my $dur = sprintf("%0.4fs", $dur_t); + my ($from, $to) = (($offset * $on_page) + 1, ($offset * $on_page) + $on_page); $retHTML .= qq{ -
Found $results files, showing $from - $to +
Found $results files showing $from - $to (took $dur)
Share