/[omni_gantt]/db2gantt.cgi
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 /db2gantt.cgi

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

revision 1.7 by dpavlin, Fri Sep 13 13:57:32 2002 UTC revision 1.9 by dpavlin, Fri Sep 13 14:34:02 2002 UTC
# Line 25  my %cols = ( Line 25  my %cols = (
25          'Completed/Errors'      => '255,128,0',          'Completed/Errors'      => '255,128,0',
26          'Completed/Failure'     => '128,0,128',          'Completed/Failure'     => '128,0,128',
27          'Mount Request'         => '128,128,255',          'Mount Request'         => '128,128,255',
28            'Mount/Errors'          => '255,64,128',
29          );          );
30    
31  my $int_t = (12 * 60 * 60);     # interval to display on one screen  my $int_t = (12 * 60 * 60);     # interval to display on one screen
# Line 34  my $min_l = 3;                 # min length of bar seg Line 35  my $min_l = 3;                 # min length of bar seg
35    
36  # time range  # time range
37    
38    $int_t = m_round($int_t);
39    
40  my ($from_t,$to_t) = (time()-$int_t,time());  my ($from_t,$to_t) = (time()-$int_t,time());
41    
42  $to_t = param('to_t') if (param('to_t'));  $to_t = param('to_t') if (param('to_t'));
43  $from_t = param('from_t') if (param('from_t'));  $from_t = param('from_t') if (param('from_t'));
44    
45  # round to nearest minute  # round to nearest minute
46  $to_t = $to_t - ($to_t % 60);  sub m_round {
47  $from_t = $from_t - ($from_t % 60) + 60;          my $t = shift @_;
48            return ($t - ($t % 60));
49    }
50    
51    $to_t = m_round($to_t);
52    $from_t = m_round($from_t);
53    
54  my $to=strftime("%Y-%m-%d %H:%M",localtime ($to_t));  my $to=strftime("%Y-%m-%d %H:%M",localtime ($to_t));
55  my $from=strftime("%Y-%m-%d %H:%M",localtime ($from_t));  my $from=strftime("%Y-%m-%d %H:%M",localtime ($from_t));
# Line 120  sub bar { Line 128  sub bar {
128    
129          my $size = int($l / ($len_t / $width));          my $size = int($l / ($len_t / $width));
130          if ($size < $min_l) {          if ($size < $min_l) {
131                    $fix_d += ($min_l - $size);
132                    print STDERR "fix_d: $fix_d\n" if ($debug);
133                  $size = $min_l;                  $size = $min_l;
                 $fix_d += $min_l;  
134          }          }
135          if ($fix_d && $size > $fix_d+$min_l) {          if ($fix_d && $size > $fix_d+$min_l) {
136                  $size -= $fix_d;                  $size -= $fix_d;
137                  $fix_d = 0;                  $fix_d = 0;
138                    print STDERR "fix_d: $fix_d\n" if ($debug);
139          }          }
140    
141          print STDERR "bar[$status] len:$l s scale:",($len_t/$width)," size:$size px<br> alt:$alt\n" if ($debug);          print STDERR "bar[$status] len:$l s scale:",($len_t/$width)," size:$size px<br> alt:$alt\n" if ($debug);
# Line 133  sub bar { Line 143  sub bar {
143          my $html = "<img src=\"".$q->url(-relative=>1)."?pic=";          my $html = "<img src=\"".$q->url(-relative=>1)."?pic=";
144    
145          if ($status) {          if ($status) {
146                  $html .= $cols{$status};                  if ($cols{$status}) {
147                            $html .= $cols{$status};
148                    } else {
149                            $html .= "0,0,0";       # unknown status, black
150                    }
151                  $count{$status}++;                  $count{$status}++;
152          } else {          } else {
153  #               $html .= '240,240,240';  #               $html .= '240,240,240';
# Line 185  while(my $row = $sth->fetchrow_hashref) Line 199  while(my $row = $sth->fetchrow_hashref)
199    
200          }          }
201    
202          my $start_t = str2time($row->{start});          my $start_t = m_round(str2time($row->{start}));
203          my $fin_t = str2time($row->{finish});          my $fin_t = m_round(str2time($row->{finish}));
204    
205          if ($start_t > $curr_t) {          if ($start_t > $curr_t + 60) {
206                  my $t = $start_t - $curr_t;                  my $t = $start_t - $curr_t;
207                  print STDERR "[middle filler $curr_t:$t]" if ($debug);                  print STDERR "[middle filler $curr_t:$t]" if ($debug);
208                  print bar($t);                  print bar($t);
# Line 251  print "<hr>\nColors for statuses and usa Line 265  print "<hr>\nColors for statuses and usa
265  print "<table border=0><tr bgcolor=#e0e0e0><th>status</th><th>#</th><th>color</th></tr>\n";  print "<table border=0><tr bgcolor=#e0e0e0><th>status</th><th>#</th><th>color</th></tr>\n";
266  foreach my $status (keys %count) {  foreach my $status (keys %count) {
267  #foreach my $status (keys %cols) {  #foreach my $status (keys %cols) {
268          print "<tr bgcolor=#e0e0e0><td><small>$status</small></td><td><small>",$count{$status}-1,"</small></td><td>",bar($count{$status},$status),"</td></tr>\n" if ($status ne "");          print "<tr bgcolor=#e0e0e0><td><small>$status</small></td><td><small>",$count{$status}*1,"</small></td><td>",bar($count{$status},$status),"</td></tr>\n" if ($status ne "");
269          # -1 in line above is a cludge to display correct number on          # *1 in line above is a cludge to display correct number on
270          # occurences on graph and without one on legend!          # occurences on graph and without one on legend! If you remove * op
271            # it will first evaluate bar sub (thus increasing number by one) and
272            # then display number (wrongly).
273  }  }
274  print "</table>\n<p>Reload <a href=\"",$q->url(-relative=>1),"\">current</a>.</p></body></html>";  print "</table>\n<p>Reload <a href=\"",$q->url(-relative=>1),"\">current</a>.</p></body></html>";
275    

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.9

  ViewVC Help
Powered by ViewVC 1.1.26