--- 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 .= "
Share |