Francois Gouget : testbot: Allow restricting the activity analysis to the recent past.

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


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

Author: Francois Gouget <fgouget at 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 at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at 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()})
   {




More information about the wine-cvs mailing list