2005-10-11 22:44:16 +04:00
|
|
|
# -*- mode: cperl; c-basic-offset: 8; indent-tabs-mode: nil; -*-
|
|
|
|
|
|
|
|
=head1 COPYRIGHT
|
|
|
|
|
|
|
|
# ***** BEGIN LICENSE BLOCK *****
|
|
|
|
# Version: MPL 1.1
|
|
|
|
#
|
|
|
|
# The contents of this file are subject to the Mozilla Public License
|
|
|
|
# Version 1.1 (the "License"); you may not use this file except in
|
|
|
|
# compliance with the License. You may obtain a copy of the License
|
|
|
|
# at http://www.mozilla.org/MPL/
|
|
|
|
#
|
|
|
|
# Software distributed under the License is distributed on an "AS IS"
|
|
|
|
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
|
|
|
# the License for the specific language governing rights and
|
|
|
|
# limitations under the License.
|
|
|
|
#
|
|
|
|
# The Original Code is Litmus.
|
|
|
|
#
|
|
|
|
# The Initial Developer of the Original Code is
|
|
|
|
# the Mozilla Corporation.
|
2006-01-25 20:03:40 +03:00
|
|
|
# Portions created by the Initial Developer are Copyright (C) 2006
|
2005-10-11 22:44:16 +04:00
|
|
|
# the Initial Developer. All Rights Reserved.
|
|
|
|
#
|
|
|
|
# Contributor(s):
|
|
|
|
# Chris Cooper <ccooper@deadsquid.com>
|
|
|
|
# Zach Lipton <zach@zachlipton.com>
|
|
|
|
#
|
|
|
|
# ***** END LICENSE BLOCK *****
|
|
|
|
|
|
|
|
=cut
|
2005-07-30 00:21:01 +04:00
|
|
|
|
|
|
|
package Litmus::DB::Subgroup;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use base 'Litmus::DBI';
|
|
|
|
|
|
|
|
use Time::Piece::MySQL;
|
|
|
|
|
|
|
|
use Litmus::DB::Testresult;
|
|
|
|
|
|
|
|
Litmus::DB::Subgroup->table('subgroups');
|
|
|
|
|
2006-02-25 01:02:41 +03:00
|
|
|
Litmus::DB::Subgroup->columns(All => qw/subgroup_id testgroup_id name sort_order testrunner_group_id enabled/);
|
2005-08-20 07:39:02 +04:00
|
|
|
|
|
|
|
Litmus::DB::Subgroup->column_alias("subgroup_id", "subgroupid");
|
|
|
|
Litmus::DB::Subgroup->column_alias("testgroup_id", "testgroup");
|
2005-07-30 00:21:01 +04:00
|
|
|
|
|
|
|
Litmus::DB::Subgroup->has_a(testgroup => "Litmus::DB::Testgroup");
|
|
|
|
|
|
|
|
Litmus::DB::Subgroup->has_many(tests => "Litmus::DB::Test");
|
|
|
|
|
2005-10-24 21:57:50 +04:00
|
|
|
#########################################################################
|
|
|
|
sub community_coverage() {
|
2005-10-11 22:44:16 +04:00
|
|
|
my $self = shift;
|
|
|
|
my $platform = shift;
|
2005-10-24 21:57:50 +04:00
|
|
|
my $build_id = shift;
|
2005-12-13 06:03:37 +03:00
|
|
|
my $locale = shift;
|
2005-10-24 21:57:50 +04:00
|
|
|
my $community_only = shift;
|
2005-10-11 22:44:16 +04:00
|
|
|
|
|
|
|
my @tests;
|
2005-10-24 21:57:50 +04:00
|
|
|
if (! $community_only) {
|
2005-10-11 22:44:16 +04:00
|
|
|
@tests = Litmus::DB::Test->search(
|
|
|
|
subgroup => $self,
|
2006-02-25 01:02:41 +03:00
|
|
|
enabled => 1,
|
2005-10-11 22:44:16 +04:00
|
|
|
);
|
|
|
|
} else {
|
|
|
|
@tests = Litmus::DB::Test->search(
|
|
|
|
subgroup => $self,
|
2006-02-25 01:02:41 +03:00
|
|
|
enabled => 1,
|
2005-10-11 22:44:16 +04:00
|
|
|
communityenabled => 1,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if (@tests == 0) { return "N/A" }
|
2005-10-24 21:57:50 +04:00
|
|
|
my $num_completed = 0;
|
2005-10-11 22:44:16 +04:00
|
|
|
foreach my $curtest (@tests) {
|
2005-12-13 06:03:37 +03:00
|
|
|
if ($curtest->is_completed($platform,$build_id,$locale)) {
|
2005-10-24 21:57:50 +04:00
|
|
|
$num_completed++;
|
2005-07-30 00:21:01 +04:00
|
|
|
}
|
2005-10-11 22:44:16 +04:00
|
|
|
}
|
2005-10-24 21:57:50 +04:00
|
|
|
|
|
|
|
my $result = $num_completed/(scalar @tests) * 100;
|
2005-10-11 22:44:16 +04:00
|
|
|
unless ($result) {
|
|
|
|
return "0";
|
|
|
|
}
|
2005-10-24 21:57:50 +04:00
|
|
|
|
|
|
|
return sprintf("%d",$result);
|
|
|
|
}
|
|
|
|
|
|
|
|
#########################################################################
|
|
|
|
sub personal_coverage() {
|
|
|
|
my $self = shift;
|
|
|
|
my $platform = shift;
|
|
|
|
my $build_id = shift;
|
2005-12-13 06:03:37 +03:00
|
|
|
my $locale = shift;
|
2005-10-24 21:57:50 +04:00
|
|
|
my $community_only = shift;
|
|
|
|
my $user = shift;
|
|
|
|
|
|
|
|
my @tests;
|
|
|
|
if (! $community_only) {
|
|
|
|
@tests = Litmus::DB::Test->search(
|
|
|
|
subgroup => $self,
|
2006-02-25 01:02:41 +03:00
|
|
|
enabled => 1,
|
2005-10-24 21:57:50 +04:00
|
|
|
);
|
2005-10-11 22:44:16 +04:00
|
|
|
} else {
|
2005-10-24 21:57:50 +04:00
|
|
|
@tests = Litmus::DB::Test->search(
|
|
|
|
subgroup => $self,
|
2006-02-25 01:02:41 +03:00
|
|
|
enabled => 1,
|
2005-10-24 21:57:50 +04:00
|
|
|
communityenabled => 1,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if (@tests == 0) { return "N/A" }
|
|
|
|
my $num_completed = 0;
|
|
|
|
foreach my $curtest (@tests) {
|
2005-12-13 06:03:37 +03:00
|
|
|
if ($curtest->is_completed($platform,$build_id,$locale,$user)) {
|
2005-10-24 21:57:50 +04:00
|
|
|
$num_completed++;
|
|
|
|
}
|
2005-10-11 22:44:16 +04:00
|
|
|
}
|
2005-10-24 21:57:50 +04:00
|
|
|
|
|
|
|
my $result = $num_completed/(scalar @tests) * 100;
|
|
|
|
unless ($result) {
|
|
|
|
return "0";
|
|
|
|
}
|
|
|
|
|
|
|
|
return sprintf("%d",$result);
|
2005-07-30 00:21:01 +04:00
|
|
|
}
|
|
|
|
|
2005-10-11 22:44:16 +04:00
|
|
|
1;
|
2005-10-24 21:57:50 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|