| WebService-TestSystem documentation | view source | Contained in the WebService-TestSystem distribution. |
WebService::TestSystem::Metrics - Metrics about use of the testing system.
my $metrics = new WebService::TestSystem::Metrics;
WebService::TestSystem::Metrics provides several routines to extract info about the testing system including number of users, tests that are getting run heavily, etc. These are intended for high level reports for users, managers, and administrators about the system itself.
The routines in this module are all considered 'public access', thus no authentication is required for retrieving them.
Establishes a new WebService::TestSystem instance. This sets up a database connection.
You must give it a valid WebService::TestSystem object in the 'app' argument.
Optionally, you can also specify the site domain name (default 'osdl.org') in the site_domain argument. This is used to determine who the 'external users' are for a given site installation. Set this to the domain name for your company to override it.
Returns the most recent error message. If any of this module's routines return undef, this routine can be called to retrieve a message about what happened. If several errors have occurred, this will only return the most recently encountered one.
Returns usage details of number of tests run and number users per month for the given year (or the current year if $year is not defined. By default returns data for all users. Specify 'external' for $user_type to limit it to only users with non-'@osdl.org' email addresses.
Returns undef if $year or $user_type are not properly defined, or if it could not obtain a database handle.
Fields returned: month year total_requests requestors =cut
sub metrics_requests_per_month { my $self = shift; my $year = shift; my $user_type = shift;
if (!$year) {
$year = (localtime)[5] + 1900;
}
return undef unless ($year =~ /^\d\d\d\d$/);
my $addy = $self->{_site_domain};
my $sql;
if (! $user_type || $user_type eq 'all') {
$sql = qq|
SELECT MONTH(test_request.completion_date) AS month ,
YEAR(test_request.completion_date) AS year,
COUNT(test_request.completion_date) AS total_requests,
COUNT(distinct(test_request.created_by)) AS requestors
FROM test_request, EIDETIC.user
WHERE YEAR(test_request.completion_date)=$year
AND test_request.created_by=EIDETIC.user.uid
GROUP BY MONTH(test_request.completion_date)|;
} elsif ($user_type eq 'external') {
$sql = qq|SELECT month(test_request.completion_date) AS month ,
YEAR(test_request.completion_date) AS year,
COUNT(test_request.completion_date) AS total_requests,
COUNT(distinct(test_request.created_by)) AS requestors
FROM test_request, EIDETIC.user
WHERE year(test_request.completion_date)=$year
AND test_request.created_by=EIDETIC.user.uid
AND EIDETIC.user.Real_email NOT LIKE '%$addy'
GROUP BY MONTH(test_request.completion_date)|;
}
my $dbh = $self->{_app}->_get_dbh() or return undef;
my $sth = $dbh->prepare($sql);
$sth->execute;
my @usage = ();
while (my $row = $sth->fetchrow_hashref) {
push @usage, $row;
}
$sth->finish;
return \@usage;
}
Returns the total hours per test for a given month
Fields returned: id test count total_run_time ave_run_time
Returns listing of different distros tested each month.
Fields returned: month count
Returns a list of total requests in each status.
Fields returned: status total
Returns the number of queued test requests for each host type
Returns the number of test requests for the given host type, for each status type.
Returns the number of test requests of different states for the past $age (default 60) days.
Returns the number of test requests per host per month for the last 90 days.
| WebService-TestSystem documentation | view source | Contained in the WebService-TestSystem distribution. |