summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Lawrence <dlawrence@mozilla.com>2013-04-11 16:16:09 +0200
committerDave Lawrence <dlawrence@mozilla.com>2013-04-11 16:16:09 +0200
commitd69ae9f2cc2d243a79dd0e4dee38dd44bccab8c3 (patch)
tree9a4668739c8b581cdfb325568e83bd5007d92a6d
parentd89e6ea5025094d0ee1561e9ba2ff739e59df26c (diff)
downloadbugzilla-d69ae9f2cc2d243a79dd0e4dee38dd44bccab8c3.tar.gz
bugzilla-d69ae9f2cc2d243a79dd0e4dee38dd44bccab8c3.tar.xz
Bug 860657 - 'Illegal division by zero' on product dashboard when the product has zero bugs
-rw-r--r--extensions/ProductDashboard/Extension.pm22
-rw-r--r--extensions/ProductDashboard/template/en/default/pages/productdashboard/summary.html.tmpl32
2 files changed, 31 insertions, 23 deletions
diff --git a/extensions/ProductDashboard/Extension.pm b/extensions/ProductDashboard/Extension.pm
index 57192f195..1e6ddffe9 100644
--- a/extensions/ProductDashboard/Extension.pm
+++ b/extensions/ProductDashboard/Extension.pm
@@ -108,8 +108,16 @@ sub _page_dashboard {
$vars->{'total_closed_bugs'} = total_closed_bugs($product);
$vars->{'severities'} = get_legal_field_values('bug_severity');
- $vars->{'open_bugs_percentage'} = int($vars->{'total_open_bugs'} / $vars->{'total_bugs'} * 100);
- $vars->{'closed_bugs_percentage'} = int($vars->{'total_closed_bugs'} / $vars->{'total_bugs'} * 100);
+ if ($vars->{'total_bugs'}) {
+ $vars->{'open_bugs_percentage'}
+ = int($vars->{'total_open_bugs'} / $vars->{'total_bugs'} * 100);
+ $vars->{'closed_bugs_percentage'}
+ = int($vars->{'total_closed_bugs'} / $vars->{'total_bugs'} * 100);
+ }
+ else {
+ $vars->{'open_bugs_percentage'} = 0;
+ $vars->{'closed_bugs_percentage'} = 0;
+ }
if ($current_tab_name eq 'summary') {
$vars->{'by_priority'} = by_priority($product, $bug_status);
@@ -142,14 +150,14 @@ sub _page_dashboard {
$vars->{'summary'} = by_value_summary($product, 'component', $input->{'component'}, $bug_status);
$vars->{'summary'}{'type'} = 'component';
$vars->{'summary'}{'value'} = $input->{'component'};
- }
+ }
elsif ($input->{'version'}) {
- $vars->{'summary'} = by_value_summary($product, 'version', $input->{'version'}, $bug_status);
+ $vars->{'summary'} = by_value_summary($product, 'version', $input->{'version'}, $bug_status);
$vars->{'summary'}{'type'} = 'version';
$vars->{'summary'}{'value'} = $input->{'version'};
- }
+ }
elsif ($input->{'target_milestone'} && Bugzilla->params->{'usetargetmilestone'}) {
- $vars->{'summary'} = by_value_summary($product, 'target_milestone', $input->{'target_milestone'}, $bug_status);
+ $vars->{'summary'} = by_value_summary($product, 'target_milestone', $input->{'target_milestone'}, $bug_status);
$vars->{'summary'}{'type'} = 'target_milestone';
$vars->{'summary'}{'value'} = $input->{'target_milestone'};
}
@@ -180,7 +188,7 @@ sub _page_dashboard {
$milestone_stats{'link_total'} = bug_milestone_link_total($product, $milestone);
$milestone_stats{'link_open'} = bug_milestone_link_open($product, $milestone);
$milestone_stats{'link_closed'} = bug_milestone_link_closed($product, $milestone);
- $milestone_stats{'percentage'} = $milestone_stats{'total_bugs'}
+ $milestone_stats{'percentage'} = $milestone_stats{'total_bugs'}
? int(($milestone_stats{'closed_bugs'} / $milestone_stats{'total_bugs'}) * 100)
: 0;
push (@{$vars->{'by_roadmap'}}, \%milestone_stats);
diff --git a/extensions/ProductDashboard/template/en/default/pages/productdashboard/summary.html.tmpl b/extensions/ProductDashboard/template/en/default/pages/productdashboard/summary.html.tmpl
index 5afba25a9..30b6f3dca 100644
--- a/extensions/ProductDashboard/template/en/default/pages/productdashboard/summary.html.tmpl
+++ b/extensions/ProductDashboard/template/en/default/pages/productdashboard/summary.html.tmpl
@@ -11,36 +11,36 @@
// global counts
PD.summary.bug_counts = [
- {
+ {
name: "Total [% terms.Bugs %]",
count: [% total_bugs || 0 FILTER js %],
- percentage: 100,
- link: '<a href="[% bug_link_all FILTER js %]">Link</a>',
- },
+ percentage: [% total_bugs ? "100" : "0" %],
+ link: '<a href="[% bug_link_all FILTER js %]">Link</a>',
+ },
{
name: "Open [% terms.Bugs %]",
count: [% total_open_bugs || 0 FILTER js %],
percentage: [% open_bugs_percentage FILTER js %],
- link: '<a href="[% bug_link_open FILTER js %]">Link</a>',
+ link: '<a href="[% bug_link_open FILTER js %]">Link</a>',
},
{
- name: "Closed [% terms.Bugs %]",
+ name: "Closed [% terms.Bugs %]",
count: [% total_closed_bugs || 0 FILTER js %],
percentage: [% closed_bugs_percentage FILTER js %],
link: '<a href="[% bug_link_closed FILTER js %]">Link</a>',
}
];
-
+
// Status counts
PD.summary.status_counts = [
[% FOREACH col = by_status %]
[% NEXT IF col.0 == 'CLOSED' %]
{
- name: "[% col.0 FILTER js %]",
+ name: "[% col.0 FILTER js %]",
count: [% col.1 || 0 FILTER js %],
- percentage: [% col.2 || 0 FILTER js %],
+ percentage: [% col.2 || 0 FILTER js %],
link: '<a href="[% bug_link_all FILTER js %]&amp;bug_status=[% col.0 FILTER uri FILTER js %]">Link</a>'
- },
+ },
[% END %]
];
@@ -48,11 +48,11 @@
PD.summary.priority_counts = [
[% FOREACH col = by_priority %]
{
- name: "[% col.0 FILTER js %]",
+ name: "[% col.0 FILTER js %]",
count: [% col.1 || 0 FILTER js %],
- percentage: [% col.2 || 0 FILTER js %],
+ percentage: [% col.2 || 0 FILTER js %],
link: '<a href="[% bug_link FILTER js %]&amp;priority=[% col.0 FILTER uri FILTER js %]">Link</a>'
- },
+ },
[% END %]
];
@@ -60,11 +60,11 @@
PD.summary.severity_counts = [
[% FOREACH col = by_severity %]
{
- name: "[% col.0 FILTER js %]",
+ name: "[% col.0 FILTER js %]",
count: [% col.1 || 0 FILTER js %],
- percentage: [% col.2 || 0 FILTER js %],
+ percentage: [% col.2 || 0 FILTER js %],
link: '<a href="[% bug_link FILTER js %]&amp;bug_severity=[% col.0 FILTER uri FILTER js %]">Link</a>'
- },
+ },
[% END %]
];