--- depotStats.cgi.old Thu May 15 09:20:45 2003
+++ depotStats.cgi Thu May 15 09:21:00 2003
@@ -30,6 +30,15 @@
$FSPC = "<tt>".join("</tt> and <tt>",@FSPC)."</tt>" ;
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(),"<hr>" ;
- # 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
+ "<h2>Statistics for \"$FSPC\"$niceAfterTimeString</h2>",
+ &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
- "<h2>Statistics for \"$FSPC\"</h2>",
- &P4CGI::start_table("") ;
printStat("Submitted changes",scalar @changes) ;
@@ -313,7 +366,7 @@
}
# Weekly Submit Statistics
-print "<a name=\"weekly\"></a><H2>Weekly Submit Rate for $FSPC</H2>",
+print "<a name=\"weekly\"></a><H2>Weekly Submit Rate for $FSPC$niceAfterTimeString</H2>",
&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
- "<a name=\"byuser\"><hr></a><h2>Submits by user in $FSPC</h2>",
+ "<a name=\"byuser\"><hr></a><h2>Submits by user in $FSPC$niceAfterTimeString</h2>",
&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 "<hr>",
+ &P4CGI::start_table("bgcolor=".&P4CGI::HDRFTR_BGCOLOR()." align=center cellpadding=0 cellspacing=2"),
+ "<tr><td>\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"),
+ "<font size=+1>$desc</font>")},
+ {-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(),
+ "<tr>",
+ "<td align=right valign=center>File spec:</td>",
+ "<td align=left valign=center><font face=fixed>",
+ &P4CGI::cgi()->textfield(-name => "FSPC",
+ -default => $FSPC,
+ -size => 50,
+ -maxlength => 256),
+ "</font></td></tr>",
+ "<td align=right valign=center>Changed within:</td>",
+ "<td align=left valign=center><font face=fixed>",
+ &P4CGI::cgi()->popup_menu(-name => "WEEKS",
+ -default => 0,
+ -values => \@weekValues,
+ -labels => \%weekValues),
+ " ",
+ "</font></td></tr>",
+ "</table>")),
+ "searchPatt") ;
+
+print &P4CGI::end_table() ;
+
+print "</tr></td>",&P4CGI::end_table() ;
+print &P4CGI::end_page() ;
+
+#
+# That's all folks
+#