diff --git a/webtools/testopia/Bugzilla/Testopia/TestCase.pm b/webtools/testopia/Bugzilla/Testopia/TestCase.pm index 5faaa34da02..123a62e70f1 100644 --- a/webtools/testopia/Bugzilla/Testopia/TestCase.pm +++ b/webtools/testopia/Bugzilla/Testopia/TestCase.pm @@ -367,6 +367,32 @@ sub get_priority_list { return $ref } +=head2 get_caserun_count + +Takes a status and returns the count of that status + +=cut + +sub get_caserun_count { + my $self = shift; + my ($status) = @_; + my $dbh = Bugzilla->dbh; + + my $query = "SELECT COUNT(*) + FROM test_case_runs + WHERE case_id = ? "; + $query .= "AND case_run_status_id = ?" if $status; + + my $count; + if ($status){ + ($count) = $dbh->selectrow_array($query,undef,($self->id,$status)); + } + else { + ($count) = $dbh->selectrow_array($query,undef,$self->id); + } + return $count; +} + =head2 add_tag Associates a tag with this test case diff --git a/webtools/testopia/template/en/default/testopia/case/show.html.tmpl b/webtools/testopia/template/en/default/testopia/case/show.html.tmpl index d7d1c0349ca..ca43eb7e605 100644 --- a/webtools/testopia/template/en/default/testopia/case/show.html.tmpl +++ b/webtools/testopia/template/en/default/testopia/case/show.html.tmpl @@ -230,6 +230,7 @@ [%##### Reports #####%]

Reports

+ [%##### Attachments #####%]

Attachments

diff --git a/webtools/testopia/template/en/default/testopia/reports/pie.png.tmpl b/webtools/testopia/template/en/default/testopia/reports/pie.png.tmpl new file mode 100644 index 00000000000..e69de29bb2d diff --git a/webtools/testopia/tr_case_reports.cgi b/webtools/testopia/tr_case_reports.cgi new file mode 100755 index 00000000000..8f470970ca2 --- /dev/null +++ b/webtools/testopia/tr_case_reports.cgi @@ -0,0 +1,78 @@ +#!/usr/bin/perl -wT +# -*- Mode: perl; indent-tabs-mode: nil -*- +# +# 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 the Bugzilla Test Runner System. +# +# The Initial Developer of the Original Code is Maciej Maczynski. +# Portions created by Maciej Maczynski are Copyright (C) 2001 +# Maciej Maczynski. All Rights Reserved. +# +# Contributor(s): Maciej Maczynski +# Ed Fuentetaja +# Greg Hendricks + +use strict; +use lib "."; + +use Bugzilla; +use Bugzilla::Constants; +use Bugzilla::Error; +use Bugzilla::Util; +use Bugzilla::Testopia::Util; +use Bugzilla::Testopia::Constants; + +use vars qw($template $vars); +my $template = Bugzilla->template; +my $cgi = Bugzilla->cgi; + +Bugzilla->login(); +print $cgi->header(); + +my $case_id = trim(Bugzilla->cgi->param('case_id') || ''); + +unless ($case_id){ + $vars->{'form_action'} = 'tr_case_reports.cgi'; + $template->process("testopia/case/choose.html.tmpl", $vars) + || ThrowTemplateError($template->error()); + exit; +} +validate_test_id($case_id, 'case'); +push @{$::vars->{'style_urls'}}, 'testopia/css/default.css'; + +my $case = Bugzilla::Testopia::TestCase->new($case_id); + +my $type = $cgi->param('type') || ''; + +if ($type eq 'status-breakdown'){ + + my @data; + my $caserun = Bugzilla::Testopia::TestCaseRun->new({}); + + my @names; + my @values; + foreach my $status (@{$caserun->get_status_list}){ + push @names, $status->{'name'}; + push @values, $case->get_caserun_count($status->{'id'}); + } + push @data, \@names; + push @data, \@values; + + $vars->{'width'} = 200; + $vars->{'height'} = 150; + $vars->{'data'} = \@data; + $vars->{'chart_title'} = 'Historic Status Breakdown'; + $vars->{'colors'} = (['#858aef', '#56e871', '#ed3f58', '#b8eae1', '#f1d9ab', '#e17a56']); + + $template->process("testopia/reports/pie.png.tmpl", $vars) + || ThrowTemplateError($template->error()); +} diff --git a/webtools/testopia/tr_plan_reports.cgi b/webtools/testopia/tr_plan_reports.cgi index 45226dae241..6fd17720bb4 100755 --- a/webtools/testopia/tr_plan_reports.cgi +++ b/webtools/testopia/tr_plan_reports.cgi @@ -32,13 +32,11 @@ use Bugzilla::Testopia::Util; use vars qw($template $vars); my $template = Bugzilla->template; +my $cgi = Bugzilla->cgi; Bugzilla->login(); -print Bugzilla->cgi->header(); +print $cgi->header(); -my $dbh = Bugzilla->dbh; -my $cgi = Bugzilla->cgi; -my $template = Bugzilla->template; my $plan_id = trim(Bugzilla->cgi->param('plan_id') || ''); unless ($plan_id){