Dzahn has submitted this change and it was merged.
Change subject: Bring WeeklyReport extension code closer to upstream
......................................................................
Bring WeeklyReport extension code closer to upstream
When it comes to coding style and other smaller changes that have
taken place in the meantime. Also update the string comparison for
"Merged in Gerrit" Bugzilla comments though I expect it to still
not work at all.
Change-Id: I793541e1187187c9bb30aa7a8de410cc534038f9
---
M extensions/WeeklyReport/component-report.cgi
M
extensions/WeeklyReport/template/en/default/weeklyreport/weekly-bug-summary.html.tmpl
M extensions/WeeklyReport/weekly-bug-summary.cgi
3 files changed, 24 insertions(+), 36 deletions(-)
Approvals:
Aklapper: Looks good to me, but someone else must approve
Dzahn: Verified; Looks good to me, approved
diff --git a/extensions/WeeklyReport/component-report.cgi
b/extensions/WeeklyReport/component-report.cgi
index e51cb48..18787ef 100755
--- a/extensions/WeeklyReport/component-report.cgi
+++ b/extensions/WeeklyReport/component-report.cgi
@@ -50,13 +50,9 @@
use Bugzilla::Product;
use Bugzilla::Constants;
use Bugzilla::Error;
+use Bugzilla::Util;
use vars qw($vars $template);
-
-eval "use GD";
-my $use_gd = $@ ? 0 : 1;
-eval "use Chart::Lines";
-$use_gd = 0 if $@;
# If we're using bug groups for products, we should apply those restrictions
# to viewing reports, as well. Time to check the login in that case.
@@ -69,7 +65,7 @@
print $cgi->header(-type => 'text/html', -expires => '+3M');
my $query = <<EOF
-SELECT count(*), products.name, components.name, bug_severity
+SELECT count(*), products.name, components.name, bug_severity
FROM bugs, products, components
WHERE ( bug_status = 'NEW' or bug_status = 'ASSIGNED' or bug_status =
'REOPENED' or bug_status = 'UNCONFIRMED' )
AND products.name = ?
@@ -83,8 +79,13 @@
#Report on components by severity and priority
my $sth = Bugzilla->dbh->prepare($query);
-my $product = $cgi->param('product');
-if ($product =~ /^([\w.-\s]+)$/) { $product = $1 }
+my $product = trim($cgi->param('product'));
+
+# FIXME: Print a "error" message
+ThrowUserError('product_blank_name') if !$product;
+
+if ($product =~ m/^([\w.-]+)$/) { $product = $1; }
+trick_taint($product);
$sth->execute($product);
my (@bug_counts, %bugs, %total_bugs);
@@ -92,6 +93,7 @@
my $total_bug_count;
my $product_obj = new Bugzilla::Product({ 'name' => $product });
+ThrowUserError('invalid_product_name', {product => $product}) if !$product_obj;
$vars->{'product'} = $product;
$vars->{'all_severities'} =
Bugzilla::Field::get_legal_field_values('bug_severity');
@@ -110,4 +112,3 @@
$template->process("weeklyreport/component-report.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
-
diff --git
a/extensions/WeeklyReport/template/en/default/weeklyreport/weekly-bug-summary.html.tmpl
b/extensions/WeeklyReport/template/en/default/weeklyreport/weekly-bug-summary.html.tmpl
index b7359be..f3ba45b 100644
---
a/extensions/WeeklyReport/template/en/default/weeklyreport/weekly-bug-summary.html.tmpl
+++
b/extensions/WeeklyReport/template/en/default/weeklyreport/weekly-bug-summary.html.tmpl
@@ -92,4 +92,3 @@
[% END %]
</select>
[% END %]
-
diff --git a/extensions/WeeklyReport/weekly-bug-summary.cgi
b/extensions/WeeklyReport/weekly-bug-summary.cgi
index f1649ed..5cda4df 100755
--- a/extensions/WeeklyReport/weekly-bug-summary.cgi
+++ b/extensions/WeeklyReport/weekly-bug-summary.cgi
@@ -13,8 +13,9 @@
use Bugzilla::Error;
use Bugzilla::Field;
-sub total_bugs_in_bugzilla()
-{
+Bugzilla->login(LOGIN_OPTIONAL);
+
+sub total_bugs_in_bugzilla() {
my $dbh = Bugzilla->dbh;
# figure out total bugs
@@ -34,8 +35,7 @@
return ($totalbugs[0], $totalwishes[0]);
}
-sub bugs_opened()
-{
+sub bugs_opened() {
my($product, $days) = @_;
my $sqlproduct = "";
@@ -51,8 +51,7 @@
return $count;
}
-sub wishes_opened()
-{
+sub wishes_opened() {
my($product, $days) = @_;
my $sqlproduct = "";
@@ -68,8 +67,7 @@
return $count;
}
-sub bugs_closed()
-{
+sub bugs_closed() {
my($product, $days) = @_;
my $query = "";
my $sqlproduct = "";
@@ -84,7 +82,7 @@
where
bugs.bug_severity != 'enhancement' AND
(bugs_activity.added='RESOLVED' or bugs_activity.added='CLOSED' or
- bugs_activity.added='NEEDSINFO')
+ bugs_activity.added='NEEDSINFO' or bugs_activity.added='VERIFIED')
and
bugs_activity.bug_when >= FROM_DAYS(TO_DAYS(NOW())-?)
and
@@ -95,8 +93,7 @@
return($count);
}
-sub wishes_closed()
-{
+sub wishes_closed() {
my($product, $days) = @_;
my $query = "";
my $sqlproduct = "";
@@ -112,7 +109,7 @@
where
bugs.bug_severity = 'enhancement' AND
(bugs_activity.added='RESOLVED' or bugs_activity.added='CLOSED' or
- bugs_activity.added='NEEDSINFO')
+ bugs_activity.added='NEEDSINFO' or bugs_activity.added='VERIFIED')
and
bugs_activity.bug_when >= FROM_DAYS(TO_DAYS(NOW())-?)
and
@@ -123,8 +120,7 @@
return($count);
}
-sub open_wishes()
-{
+sub open_wishes() {
my($product) = @_;
my $sqlproduct = "";
@@ -185,7 +181,6 @@
$product_id{$product} = $p_id;
}
-
foreach my $product (reverse sort
{$product_count{$a} <=> $product_count{$b}}
keys (%product_count)) {
@@ -231,7 +226,7 @@
bugs, bugs_activity, profiles assign
where
(bugs_activity.added='RESOLVED' or bugs_activity.added = 'CLOSED' or
- bugs_activity.added='NEEDSINFO')
+ bugs_activity.added='NEEDSINFO' or bugs_activity.added='VERIFIED')
and
bugs_activity.bug_when >= from_days(TO_DAYS(NOW()) - ?)
and
@@ -239,7 +234,8 @@
and
bugs.bug_id = bugs_activity.bug_id
and
- (bugs.bug_status = 'RESOLVED' or bugs.bug_status = 'CLOSED')
+ (bugs.bug_status = 'RESOLVED' or bugs.bug_status = 'CLOSED' or
+ bugs_activity.added='VERIFIED')
group by assign.login_name
order by n desc
limit ?
@@ -291,7 +287,7 @@
AND
longdescs.who = bugs_activity.who
AND
- longdescs.thetext like \"%change APPROVED and MERGED%\"
+ longdescs.thetext like \"%merged by jenkins-bot%\"
GROUP BY
profiles.login_name, bugs.bug_id
ORDER BY
@@ -320,9 +316,6 @@
return \@results;
}
-
-
-Bugzilla->login(LOGIN_OPTIONAL);
# For most scripts we don't make $cgi and $template global variables. But
# when preparing Bugzilla for mod_perl, this script used these
@@ -380,9 +373,4 @@
$template->process("weeklyreport/weekly-bug-summary.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
-
-
-
-
print "</div>\n";
-
--
To view, visit https://gerrit.wikimedia.org/r/96479
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I793541e1187187c9bb30aa7a8de410cc534038f9
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/bugzilla/modifications
Gerrit-Branch: master
Gerrit-Owner: Aklapper <[email protected]>
Gerrit-Reviewer: Aklapper <[email protected]>
Gerrit-Reviewer: Dzahn <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits