Module: tools
Branch: master
Commit: 2dacba044866c50da175722e135848568d90e9fc
URL: https://source.winehq.org/git/tools.git/?a=commit;h=2dacba044866c50da175722…
Author: Francois Gouget <fgouget(a)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(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)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;
-@ActivityPage::ISA = qw(ObjectModel::CGI::Page);
+@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];
Module: tools
Branch: master
Commit: afd2f80cbdc03e331c1ed64305edc2d719ee3689
URL: https://source.winehq.org/git/tools.git/?a=commit;h=afd2f80cbdc03e331c1ed64…
Author: Francois Gouget <fgouget(a)codeweavers.com>
Date: Tue Jan 23 05:33:59 2018 +0100
testbot: Allow restricting the activity analysis to the recent past.
GetActivity() now takes the number of seconds of recent activity to
analyze and uses it to limit the number of records and record groups
that are retrieved from the database. This can greatly speed up the
analysis.
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
testbot/lib/WineTestBot/Activity.pm | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/testbot/lib/WineTestBot/Activity.pm b/testbot/lib/WineTestBot/Activity.pm
index 58169ae..fb2cee5 100644
--- a/testbot/lib/WineTestBot/Activity.pm
+++ b/testbot/lib/WineTestBot/Activity.pm
@@ -43,8 +43,8 @@ require Exporter;
=item C<GetActivity()>
-Loads the records for the specified VMs and processes them to build a structure
-describing the TestBot activity.
+Loads the records for the specified VMs going back the specified number of
+seconds and processes them to build a structure describing the TestBot activity.
Returns a list of the activity records, sorted from the oldest to the newest.
Each entry contains a structure grouping all the state and event information
@@ -90,19 +90,31 @@ that were processed.
=back
=cut
-sub GetActivity($)
+sub GetActivity($;$)
{
- my ($VMs) = @_;
+ my ($VMs, $Seconds) = @_;
my ($ActivityHash, $Activity, $Counters) = ({}, [], {});
### First load all the RecordGroups
my $RecordGroups = CreateRecordGroups();
+ if ($Seconds)
+ {
+ $RecordGroups->AddFilter("Timestamp", [time() - $Seconds], ">=");
+ }
+ my $MinId;
$Counters->{recordgroups} = $RecordGroups->GetItemsCount();
foreach my $RecordGroup (sort CompareRecordGroups @{$RecordGroups->GetItems()})
{
my $Group = { start => $RecordGroup->Timestamp };
$ActivityHash->{$RecordGroup->Id} = $Group;
push @$Activity, $Group;
+ $MinId = $RecordGroup->Id if (!defined $MinId or $RecordGroup->Id < $MinId);
+ }
+ if (!defined $MinId)
+ {
+ # No activity was found in the specified period
+ $Counters->{records} = 0;
+ return ($Activity, $Counters);
}
### And then load all the Records in one go
@@ -111,6 +123,7 @@ sub GetActivity($)
my $Jobs = CreateJobs();
my $Records = CreateRecords();
+ $Records->AddFilter("RecordGroupId", [$MinId], ">=");
$Counters->{records} = $Records->GetItemsCount();
foreach my $Record (@{$Records->GetItems()})
{