Module: tools
Branch: master
Commit: e0308935cae533eba5797fa12f944cf2ac3ffaab
URL: https://source.winehq.org/git/tools.git/?a=commit;h=e0308935cae533eba5797fa…
Author: Francois Gouget <fgouget(a)codeweavers.com>
Date: Thu Mar 10 12:00:49 2022 +0100
testbot/web: Better initialize and check the Days Stats page parameter.
Use SetParam() to provide the default value. This allows removing the
Days field and GetDisplayValue() method.
FormPage::Validate() must be called after the property descriptors
have been set otherwise it has no property to check. This removes the
need for redefining Validate().
Treat "00" the same as "0".
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
testbot/web/Stats.pl | 31 ++++---------------------------
1 file changed, 4 insertions(+), 27 deletions(-)
diff --git a/testbot/web/Stats.pl b/testbot/web/Stats.pl
index c96e6fd..42408a3 100644
--- a/testbot/web/Stats.pl
+++ b/testbot/web/Stats.pl
@@ -37,34 +37,18 @@ sub _initialize($$$)
{
my ($self, $Request, $RequiredRole) = @_;
- $self->{Days} = $self->GetParam("Days");
- $self->Validate();
-
$self->{start} = Time();
my @PropertyDescriptors = (
CreateBasicPropertyDescriptor("Days", "Days to analyze", !1, 1, "N", 2),
);
$self->SUPER::_initialize($Request, $RequiredRole, \@PropertyDescriptors);
-}
-
-sub Validate($)
-{
- my ($self) = @_;
- if (!defined $self->{Days})
- {
- $self->{Days} = 7;
- $self->{NoStats} = 1;
- }
- elsif ($self->{Days} !~ /^[0-9]{1,2}$/)
+ if (!$self->GetParam("Days") or !$self->Validate() or
+ !int($self->GetParam("Days"))) # 00 case!
{
- $self->{ErrField} = "Days";
- $self->{ErrMessage} = "The number of days must be between 1 and 99";
+ $self->SetParam("Days", 7) if (!defined $self->{ErrMessage});
$self->{NoStats} = 1;
- $self->{Days} = 7;
- return undef;
}
- return $self->SUPER::Validate();
}
sub GetPageTitle($$)
@@ -211,7 +195,7 @@ sub GenerateBody($)
my $VMs = CreateVMs();
$VMs->FilterEnabledRole();
my @SortedVMs = sort _CompareVMs @{$VMs->GetItems()};
- my $Stats = GetStatistics($VMs, $self->{Days} * 24 * 60 * 60);
+ my $Stats = GetStatistics($VMs, $self->GetParam("Days") * 24 * 60 * 60);
### Show global statistics
@@ -377,13 +361,6 @@ sub GenerateBody($)
print "</tbody></table></div>\n";
}
-sub GetDisplayValue($$)
-{
- my ($self, $PropertyDescriptor) = @_;
-
- return $self->{$PropertyDescriptor->GetName()};
-}
-
sub GetActions($)
{
#my ($self) = @_;
Module: tools
Branch: master
Commit: 96b5a4449a453e83a2f372b5bd03fcdd30511462
URL: https://source.winehq.org/git/tools.git/?a=commit;h=96b5a4449a453e83a2f372b…
Author: Francois Gouget <fgouget(a)codeweavers.com>
Date: Thu Mar 10 12:00:39 2022 +0100
testbot/web: Better initialize and check the Hours Log page parameter.
Call Validate() to make sure the Hours parameter is usable. Note that
due to an implementation detail marking the Hours property as required
is not strictly necessary. But it does reflect that we need a value for
the Download action.
Use SetParam() to provide a default value which removes the need for
redefining GetPropertyValue().
Treat "00" the same as "0".
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
testbot/web/admin/Log.pl | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/testbot/web/admin/Log.pl b/testbot/web/admin/Log.pl
index 456e73f..f8e4943 100644
--- a/testbot/web/admin/Log.pl
+++ b/testbot/web/admin/Log.pl
@@ -34,9 +34,16 @@ sub _initialize($$$)
my ($self, $Request, $RequiredRole) = @_;
my @PropertyDescriptors = (
- CreateBasicPropertyDescriptor("Hours", "Hours", !1, !1, "N", 2),
+ CreateBasicPropertyDescriptor("Hours", "Hours", !1, 1, "N", 2),
);
$self->SUPER::_initialize($Request, $RequiredRole, \@PropertyDescriptors);
+
+ if (!$self->GetParam("Hours") or !$self->Validate() or
+ !int($self->GetParam("Hours"))) # 00 case!
+ {
+ $self->SetParam("Hours", 1) if (!defined $self->{ErrMessage});
+ $self->SetParam("Action", undef);
+ }
}
sub GetPageTitle($$)
@@ -46,16 +53,6 @@ sub GetPageTitle($$)
return "Engine Log - ${ProjectName} Test Bot";
}
-sub GetPropertyValue($$)
-{
- my ($self, $PropertyDescriptor) = @_;
-
- my $PropertyName = $PropertyDescriptor->GetName();
- return 1 if ($PropertyName eq "Hours"); # Provides a default value
-
- return $self->SUPER::GetPropertyValue($PropertyDescriptor);
-}
-
sub GetHeaderText($)
{
#my ($self) = @_;