-sub getBackupsNotBurned()
- {
- my $dbh = DBI->connect( "dbi:SQLite:dbname=${TopDir}/$Conf{SearchDB}",
- "", "", { RaiseError => 1, AutoCommit => 1 } );
- my $sql = q{
- SELECT
- hosts.ID AS hostID,
- hosts.name AS host,
- backups.num AS backupno,
- backups.type AS type,
- backups.date AS date
- FROM backups, shares, files, hosts
- 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
- };
- my $st = $dbh -> prepare( $sql );
- my @ret = ();
- $st -> execute();
-
- while ( my $tmp = $st -> fetchrow_hashref() )
- {
- push(@ret, {
- 'host' => $tmp->{'host'},
- 'hostid' => $tmp->{'hostID'},
- 'backupno' => $tmp->{'backupno'},
- 'type' => $tmp->{'type'},
- 'date' => $tmp->{'date'}
- }
- );
+sub getFilesHyperEstraier($) {
+ my ($param) = @_;
+
+ my $offset = $param->{'offset'} || 0;
+ $offset *= $on_page;
+
+ die "no index_path?" unless ($index_path);
+
+ use HyperEstraier;
+
+ # open the database
+ my $db = HyperEstraier::Database->new();
+ $db->open($index_path, $HyperEstraier::ESTDBREADER);
+
+ # create a search condition object
+ my $cond = HyperEstraier::Condition->new();
+
+ my $q = $param->{'search_filename'};
+ my $shareid = $param->{'search_share'};
+
+ if ($q) {
+ $q =~ s/(.)/$1 /g;
+
+ # set the search phrase to the search condition object
+ $cond->set_phrase($q);
+ }
+
+ my ($backup_from, $backup_to, $files_from, $files_to) = dates_from_form($param);
+
+ $cond->add_attr("backup_date NUMGE $backup_from") if ($backup_from);
+ $cond->add_attr("backup_date NUMLE $backup_to") if ($backup_to);
+
+ $cond->add_attr("date NUMGE $files_from") if ($files_from);
+ $cond->add_attr("date NUMLE $files_to") if ($files_to);
+
+ $cond->add_attr("shareid NUMEQ $shareid") if ($shareid);
+
+# $cond->set_max( $offset + $on_page );
+ $cond->set_options( $HyperEstraier::Condition::SURE );
+ $cond->set_order( 'date NUMA' );
+
+ # get the result of search
+ my $result = $db->search($cond, 0);
+
+ my @res;
+ my $hits = $result->size;
+
+ # for each document in result
+ for my $i ($offset .. ($offset + $on_page - 1)) {
+ last if ($i >= $hits);
+
+ my $id = $result->get($i);
+ my $doc = $db->get_doc($id, 0);
+
+ my $row;
+ foreach my $c (qw/fid hname sname backupnum fiilename filepath date type size/) {
+ $row->{$c} = $doc->attr($c);
+ }
+ push @res, $row;
+ }
+
+ return ($hits, \@res);
+}
+
+sub getBackupsNotBurned() {
+
+ my $dbh = get_dbh();
+ my $sql = q{
+ SELECT
+ backups.hostID AS hostid,
+ min(hosts.name) AS host,
+ backups.num AS backupnum,
+ min(backups.type) AS type,
+ min(backups.date) AS date,
+ min(backups.size) AS size
+ 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 AND backups.shareID = shares.ID
+ GROUP BY
+ backups.hostID, backups.num
+ ORDER BY min(backups.date)
+ };
+ my $sth = $dbh->prepare( $sql );
+ my @ret;
+ $sth->execute();
+
+ 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;