/[BackupPC]/trunk/lib/BackupPC/SearchLib.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/BackupPC/SearchLib.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 149 by dpavlin, Fri Oct 7 12:27:07 2005 UTC revision 186 by dpavlin, Wed Oct 12 12:53:27 2005 UTC
# Line 68  sub dates_from_form($) { Line 68  sub dates_from_form($) {
68                  $mm =~ s/\D//g;                  $mm =~ s/\D//g;
69                  $dd =~ s/\D//g;                  $dd =~ s/\D//g;
70    
71                    my $h = my $m = my $s = 0;
72                    if ($suffix eq 'to') {
73                            $h = 23;
74                            $m = 59;
75                            $s = 59;
76                    }
77    
78                  my $dt = new DateTime(                  my $dt = new DateTime(
79                          year => $yyyy,                          year => $yyyy,
80                          month => $mm,                          month => $mm,
81                          day => $dd                          day => $dd,
82                            hour => $h,
83                            minute => $m,
84                            second => $s,
85                  );                  );
86                  print STDERR "mk_epoch_date($name,$suffix) [$yyyy-$mm-$dd] = " . $dt->ymd . " " . $dt->hms . "\n";                  print STDERR "mk_epoch_date($name,$suffix) [$yyyy-$mm-$dd] = " . $dt->ymd . " " . $dt->hms . "\n";
87                  return $dt->epoch || 'NULL';                  return $dt->epoch || 'NULL';
# Line 100  sub getWhere($) { Line 110  sub getWhere($) {
110          push @conditions, qq{ files.date >= $files_from } if ($files_from);          push @conditions, qq{ files.date >= $files_from } if ($files_from);
111          push @conditions, qq{ files.date <= $files_to } if ($files_to);          push @conditions, qq{ files.date <= $files_to } if ($files_to);
112    
113          print STDERR "backup: $backup_from - $backup_to files: $files_from - $files_to cond:" . join(" | ",@conditions);          print STDERR "backup: $backup_from - $backup_to files: $files_from - $files_to cond:" . join(" and ",@conditions);
114    
115          push( @conditions, ' files.shareid = ' . $param->{'search_share'} ) if ($param->{'search_share'});          push( @conditions, ' files.shareid = ' . $param->{'search_share'} ) if ($param->{'search_share'});
116          push (@conditions, " upper(files.path) LIKE upper('%".$param->{'search_filename'}."%')") if ($param->{'search_filename'});          push (@conditions, " upper(files.path) LIKE upper('%".$param->{'search_filename'}."%')") if ($param->{'search_filename'});
# Line 288  sub getGzipName($$$) Line 298  sub getGzipName($$$)
298          $ret =~ s/\\h/$host/ge;          $ret =~ s/\\h/$host/ge;
299          $ret =~ s/\\s/$share/ge;          $ret =~ s/\\s/$share/ge;
300          $ret =~ s/\\n/$backupnum/ge;          $ret =~ s/\\n/$backupnum/ge;
301            
302            $ret =~ s/__+/_/g;
303    
304          return $ret;          return $ret;
305                    
306  }  }
# Line 335  sub getBackupsNotBurned() { Line 347  sub getBackupsNotBurned() {
347                          backups.type AS type,                          backups.type AS type,
348                          backups.date AS date,                          backups.date AS date,
349                          backups.size AS size,                          backups.size AS size,
350                          backups.id AS id                          backups.id AS id,
351                            backups.inc_size AS inc_size
352                  FROM backups                  FROM backups
353                  INNER JOIN shares       ON backups.shareID=shares.ID                  INNER JOIN shares       ON backups.shareID=shares.ID
354                  INNER JOIN hosts        ON backups.hostID = hosts.ID                  INNER JOIN hosts        ON backups.hostID = hosts.ID
355                  LEFT OUTER JOIN archive_backup ON archive_backup.backup_id = backups.id                  LEFT OUTER JOIN archive_backup ON archive_backup.backup_id = backups.id
356                  WHERE backups.size > 0 AND archive_backup.backup_id IS NULL                  WHERE backups.inc_size > 0 AND backups.inc_deleted is false AND archive_backup.backup_id IS NULL
357                  GROUP BY                  GROUP BY
358                          backups.hostID,                          backups.hostID,
359                          hosts.name,                          hosts.name,
# Line 350  sub getBackupsNotBurned() { Line 363  sub getBackupsNotBurned() {
363                          backups.id,                          backups.id,
364                          backups.type,                          backups.type,
365                          backups.date,                          backups.date,
366                          backups.size                          backups.size,
367                            backups.inc_size
368                  ORDER BY backups.date                  ORDER BY backups.date
369          };          };
370          my $sth = $dbh->prepare( $sql );          my $sth = $dbh->prepare( $sql );
# Line 360  sub getBackupsNotBurned() { Line 374  sub getBackupsNotBurned() {
374          while ( my $row = $sth->fetchrow_hashref() ) {          while ( my $row = $sth->fetchrow_hashref() ) {
375                  $row->{'age'} = sprintf("%0.1f", ( (time() - $row->{'date'}) / 86400 ) );                  $row->{'age'} = sprintf("%0.1f", ( (time() - $row->{'date'}) / 86400 ) );
376                  $row->{'size'} = sprintf("%0.2f", $row->{'size'} / 1024 / 1024);                  $row->{'size'} = sprintf("%0.2f", $row->{'size'} / 1024 / 1024);
377                  my (undef,undef,undef,undef,undef,undef,undef,$fs_size,undef,undef,undef,undef,undef) =  
378                          stat( $Conf{InstallDir}.'/'.$Conf{GzipTempDir}.'/'.                  # do some cluster calculation (approximate) and convert to kB
379                                  getGzipName($row->{'host'}, $row->{share}, $row->{'backupnum'}));                  $row->{'inc_size'} = int(($row->{'inc_size'} + 1023 ) / ( 2 * 1024 ) * 2);
                 $row->{'fs_size'} = $fs_size;  
380                  push @ret, $row;                  push @ret, $row;
381          }          }
382                
# Line 686  EOF3 Line 699  EOF3
699                          <td align="center">date</td>                          <td align="center">date</td>
700                          <td align="center">age/days</td>                          <td align="center">age/days</td>
701                          <td align="center">size/MB</td>                          <td align="center">size/MB</td>
702                          <td align="center">gzip size</td>                          <td align="center">gzip size/kB</td>
703                          </tr>                          </tr>
704    
705          };          };
# Line 710  EOF3 Line 723  EOF3
723                          '<tr' . $color[$i %2 ] . '>                          '<tr' . $color[$i %2 ] . '>
724                          <td class="fview">';                          <td class="fview">';
725    
726                  # FIXME                  if (($backup->{'inc_size'} || 0) > 0) {
                 $backup->{'fs_size'} = int($backup->{'size'} * 1024);  
   
                 if (($backup->{'fs_size'} || 0) > 0) {  
727                          $retHTML .= '                          $retHTML .= '
728                          <input type="checkbox" name="fcb' . $checkbox_key . '" value="' . $checkbox_key . '" onClick="sumiraj(this);">';                          <input type="checkbox" name="fcb' . $checkbox_key . '" value="' . $checkbox_key . '" onClick="sumiraj(this);">';
729                  }                  }
# Line 726  EOF3 Line 736  EOF3
736                          '<td align="center">' . epoch_to_iso( $backup->{'date'} ) . '</td>' .                          '<td align="center">' . epoch_to_iso( $backup->{'date'} ) . '</td>' .
737                          '<td align="center">' . $backup->{'age'} . '</td>' .                          '<td align="center">' . $backup->{'age'} . '</td>' .
738                          '<td align="right">' . $backup->{'size'} . '</td>' .                          '<td align="right">' . $backup->{'size'} . '</td>' .
739                          '<td align="right">' . $backup->{'fs_size'} .                          '<td align="right">' . $backup->{'inc_size'} .
740                          '<input type="hidden" iD="fss'.$checkbox_key .'" value="'. $backup->{'fs_size'} .'"></td>' .                          '<input type="hidden" iD="fss'.$checkbox_key .'" value="'. $backup->{'inc_size'} .'"></td>' .
741    
742                          "</tr>\n";                          "</tr>\n";
743          }          }

Legend:
Removed from v.149  
changed lines
  Added in v.186

  ViewVC Help
Powered by ViewVC 1.1.26