Francois Gouget : testbot: Filter the jobs in GetStatistics().
Module: tools Branch: master Commit: 8f4e6c03f9aae9312d18ce0347995442946fc355 URL: https://source.winehq.org/git/tools.git/?a=commit;h=8f4e6c03f9aae9312d18ce03... Author: Francois Gouget <fgouget(a)codeweavers.com> Date: Thu Apr 14 16:57:57 2022 +0200 testbot: Filter the jobs in GetStatistics(). This reduces the number of Tasks that need to be loaded from the database and processed in order to collect the statistics for short periods of time. Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- testbot/lib/WineTestBot/Activity.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/testbot/lib/WineTestBot/Activity.pm b/testbot/lib/WineTestBot/Activity.pm index f757905..d395a12 100644 --- a/testbot/lib/WineTestBot/Activity.pm +++ b/testbot/lib/WineTestBot/Activity.pm @@ -31,6 +31,8 @@ our @EXPORT = qw(GetActivity GetStatistics); use List::Util qw(max); use Scalar::Util qw(weaken); +use ObjectModel::Collection; + use WineTestBot::Config; use WineTestBot::Jobs; use WineTestBot::RecordGroups; @@ -342,9 +344,12 @@ sub GetStatistics($;$) my ($GlobalStats, $HostsStats, $VMsStats) = ({}, {}, {}); - my @JobTimes; my $Jobs = CreateJobs(); my $Cutoff = $Seconds ? (time() - $Seconds) : 0; + $Jobs->AddFilter(FilterOr(FilterNull("Ended"), + FilterValue("Ended", ">=", [$Cutoff]))); + + my @JobTimes; foreach my $Job (@{$Jobs->GetItems()}) { my $CountsAsNew = ($Job->Submitted >= $Cutoff); @@ -372,6 +377,7 @@ sub GetStatistics($;$) $GlobalStats->{"newtasks.count"}++; $HostStats->{"newtasks.count"}++ if ($HostStats); } + # The Task may have ended much earlier than the Job next if (!$Task->Ended or $Task->Ended < $Cutoff); $GlobalStats->{"donetasks.count"}++; $HostStats->{"donetasks.count"}++ if ($HostStats);
participants (1)
-
Alexandre Julliard