Francois Gouget : testbot/web: Default to reporting on the activity of the past 24 hours.

Alexandre Julliard julliard at winehq.org
Tue Jan 23 14:41:46 CST 2018


Module: tools
Branch: master
Commit: 2dacba044866c50da175722e135848568d90e9fc
URL:    https://source.winehq.org/git/tools.git/?a=commit;h=2dacba044866c50da175722e135848568d90e9fc

Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Tue Jan 23 05:34:34 2018 +0100

testbot/web: Default to reporting on the activity of the past 24 hours.

This limits the time it takes to generate the activity page.
One can still review the full activity log by specifying 0 as the time
period to analyze.
Also the page no longer self-refreshes for periods longer than the
default.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 testbot/web/Activity.pl | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/testbot/web/Activity.pl b/testbot/web/Activity.pl
index f8b7b5a..0b92299 100644
--- a/testbot/web/Activity.pl
+++ b/testbot/web/Activity.pl
@@ -24,27 +24,37 @@ package ActivityPage;
 use POSIX qw(strftime);
 use URI::Escape;
 
-use ObjectModel::CGI::Page;
+use ObjectModel::CGI::FreeFormPage;
 use WineTestBot::Config;
 use WineTestBot::Activity;
 use WineTestBot::Log;
 use WineTestBot::VMs;
 
- at ActivityPage::ISA = qw(ObjectModel::CGI::Page);
+ at ActivityPage::ISA = qw(ObjectModel::CGI::FreeFormPage);
+
+my $HOURS_DEFAULT = 24;
 
 sub _initialize($$$)
 {
   my ($self, $Request, $RequiredRole) = @_;
 
   $self->{start} = Time();
+  $self->{hours} = $self->GetParam("Hours");
+  if (!defined $self->{hours} or $self->{hours} !~ /^\d{1,3}$/)
+  {
+    $self->{hours} = $HOURS_DEFAULT;
+  }
+
   $self->SUPER::_initialize($Request, $RequiredRole);
 }
 
 sub GeneratePage($)
 {
   my ($self) = @_;
-
-  $self->{Request}->headers_out->add("Refresh", "60");
+  if ($self->{hours} and $self->{hours} <= $HOURS_DEFAULT)
+  {
+    $self->{Request}->headers_out->add("Refresh", "60");
+  }
   $self->SUPER::GeneratePage();
 }
 
@@ -88,6 +98,11 @@ sub GenerateBody($)
 {
   my ($self) = @_;
 
+  # Generate a custom form to let the user specify the Hours field.
+  $self->GenerateFormStart();
+  print "<div class='ItemProperty'><label>Analyze the activity of the past <div class='ItemValue'><input type='text' name='Hours' maxlength='3' size='3' value='$self->{hours}'/></div> hours.</div>\n";
+  $self->GenerateFormEnd();
+
   print "<h1>${ProjectName} Test Bot activity</h1>\n";
   print "<div class='Content'>\n";
 
@@ -132,7 +147,7 @@ EOF
   ### Generate the HTML table with the newest record first
 
   print "<tbody>\n";
-  my ($Activity, $_Counters) = GetActivity($VMs);
+  my ($Activity, $_Counters) = GetActivity($VMs, $self->{hours} * 3600);
   for (my $Index = @$Activity; $Index--; )
   {
     my $Group = $Activity->[$Index];




More information about the wine-cvs mailing list