--- depotStats.cgi.old Thu May 15 09:20:45 2003 +++ depotStats.cgi Thu May 15 09:21:00 2003 @@ -30,6 +30,15 @@ $FSPC = "".join(" and ",@FSPC)."" ; my $FSPCcmd = "\"" . join("\" \"",@FSPC) . "\"" ; +my $WEEKS = P4CGI::cgi()->param("WEEKS") ; +if(defined $WEEKS) { + &P4CGI::bail("Parameter WEEKS non-numeric") unless $WEEKS =~ /^\d+$/ ; +} +else { + $WEEKS = 0 ; +} + + ### ### subroutine findTime ### A (really) poor mans version of mktime(3). @@ -125,7 +134,55 @@ print &P4CGI::end_table(),"
" ; - # Get changes + + # Get labels for the change list +my $currentTimeString = "" ; +my $afterTimeString = "" ; +my $niceAfterTimeString = "" ; +my $seconds = 3600 * 24 * 7 * $WEEKS ; +if($seconds) { +# +# get time strings to compare to +# + my $time = time() ; + my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($time) ; + $currentTimeString = sprintf("\@%d/%02.2d/%02.2d:%02.2d:%02.2d:%02.2d", + 1900+$year,$mon+1,$mday,$hour,$min,$sec) ; + + ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($time - $seconds); + $afterTimeString = sprintf("\@%d/%02.2d/%02.2d:%02.2d:%02.2d:%02.2d", + 1900+$year,$mon+1,$mday,$hour,$min,$sec) ; + $niceAfterTimeString = sprintf(" since %d/%02.2d/%02.2d %02.2d:%02.2d", + 1900+$year,$mon+1,$mday,$hour,$min) ; + +# +# Update the file spec command +# + $FSPCcmd .= $afterTimeString . "," . $currentTimeString ; +} + + ## File list stats +print + "

Statistics for \"$FSPC\"$niceAfterTimeString

", + &P4CGI::start_table("") ; + + # Get pending changes +my @changes ; +&P4CGI::p4call(\@changes,"changes -s pending $FSPCcmd") ; + # Sort and remove duplicates +{ + my @ch = sort { $a =~ /Change (\d+)/ ; my $ac = $1 ; + $b =~ /Change (\d+)/ ; my $bc = $1 ; + $bc <=> $ac } @changes ; + my $last="" ; + @changes = grep {my $l = $last ; + $last = $_ ; + $_ ne $l } @ch ; +} + +printStat("Pending changes",scalar @changes) ; + + # Get submitted changes my @changes ; &P4CGI::p4call(\@changes,"changes -s submitted $FSPCcmd") ; # Sort and remove duplicates @@ -138,10 +195,6 @@ $last = $_ ; $_ ne $l } @ch ; } - ## File list stats -print - "

Statistics for \"$FSPC\"

", - &P4CGI::start_table("") ; printStat("Submitted changes",scalar @changes) ; @@ -313,7 +366,7 @@ } # Weekly Submit Statistics -print "

Weekly Submit Rate for $FSPC

", +print "

Weekly Submit Rate for $FSPC$niceAfterTimeString

", &P4CGI::start_table("width=90%"), &P4CGI::table_row({-type=>"th", -text => "Week starting", @@ -331,6 +384,7 @@ foreach $d (sort { $b cmp $a } keys %dailySubStat) { print &P4CGI::start_table("colums=4 width=90% cellspacing=0") ; my $n = $dailySubStat{$d} ; + $max = 1 if $max == 0 ; my $w = int((65.0 * $n)/$max) ; if($w == 0) { $w = 1 ; } ; print &P4CGI::table_row({-text => "$d", @@ -349,7 +403,7 @@ # Submits per user print - "

Submits by user in $FSPC

", + "

Submits by user in $FSPC$niceAfterTimeString

", &P4CGI::start_table("width=90%"), &P4CGI::table_row({-type=>"th", -text => "User", @@ -400,17 +454,94 @@ } -print &P4CGI::end_page() ; - -# -# That's all folks -# - +# Allow the page to change the FileSpec and the weeks +print "
", + &P4CGI::start_table("bgcolor=".&P4CGI::HDRFTR_BGCOLOR()." align=center cellpadding=0 cellspacing=2"), + "\n" ; +sub prSelection($$$$ ) +{ + my $cgitarget = shift @_ ; + my $desc = shift @_ ; + my $fields = shift @_ ; + my $helpTarget = shift @_ ; + + print "", &P4CGI::table_row(-valign=>"center", + {-align=>"center", + -text => + join("\n", + &P4CGI::cgi()->startform(-action => $cgitarget, + -method => "GET"), + "$desc")}, + {-align=>"left", + -valign=>"top", + -text => $fields}, + {-align=>"left", + -text => " "}, + {-align=>"left", + -valign=>"bottom", + -width=>"1", + -text => &P4CGI::cgi()->submit(-name => "ignore", + -value => "GO!") + }, + { -valign=>"bottom", + -text => &P4CGI::cgi()->endform() + }, + ) ; +} ; +print "", &P4CGI::start_table("width=100% cellspacing=4") ; +my %weekValues = ( 0 => "- Default -", + 1 => "One week", + 2 => "Two weeks", + 3 => "Three weeks", + 4 => "Four weeks", + 5 => "Five weeks", + 6 => "Six weeks", + 7 => "Seven weeks", + 8 => "Eight weeks", + 9 => "Nine weeks") ; +{ + my $n = 9 ; + while($n++ < 24) { + $weekValues{$n} = "$n weeks" ; + } +} +my @weekValues = sort { $a <=> $b } keys %weekValues ; + +prSelection("depotStats.cgi", + "Statics in the depot", + join("\n",(&P4CGI::start_table(), + "", + "File spec:", + "", + &P4CGI::cgi()->textfield(-name => "FSPC", + -default => $FSPC, + -size => 50, + -maxlength => 256), + "", + "Changed within:", + "", + &P4CGI::cgi()->popup_menu(-name => "WEEKS", + -default => 0, + -values => \@weekValues, + -labels => \%weekValues), + " ", + "", + "")), + "searchPatt") ; + +print &P4CGI::end_table() ; + +print "",&P4CGI::end_table() ; +print &P4CGI::end_page() ; + +# +# That's all folks +#