summaryrefslogtreecommitdiffstats
path: root/extensions
diff options
context:
space:
mode:
authorByron Jones <bjones@mozilla.com>2012-01-12 06:54:26 +0100
committerByron Jones <bjones@mozilla.com>2012-01-12 06:54:26 +0100
commit4d17d8c23a258aa43218a000bba9c917b9472232 (patch)
tree95b5d6d20df379fb69c0b4f18ae8f71646ec0934 /extensions
parenta16d7573b3163029e65ec1f14f44df58eae9c66a (diff)
downloadbugzilla-4d17d8c23a258aa43218a000bba9c917b9472232.tar.gz
bugzilla-4d17d8c23a258aa43218a000bba9c917b9472232.tar.xz
Bug 715424: add report showing emails in TheSchwartz's queue
Diffstat (limited to 'extensions')
-rw-r--r--extensions/BMO/Extension.pm6
-rw-r--r--extensions/BMO/lib/Reports.pm27
-rw-r--r--extensions/BMO/template/en/default/hook/global/user-error-auth_failure_object.html.tmpl2
-rw-r--r--extensions/BMO/template/en/default/hook/reports/menu-end.html.tmpl4
-rw-r--r--extensions/BMO/template/en/default/pages/email_queue.html.tmpl53
-rw-r--r--extensions/BMO/web/styles/reports.css14
6 files changed, 97 insertions, 9 deletions
diff --git a/extensions/BMO/Extension.pm b/extensions/BMO/Extension.pm
index 44a1a3e69..3cf0e8317 100644
--- a/extensions/BMO/Extension.pm
+++ b/extensions/BMO/Extension.pm
@@ -56,7 +56,8 @@ use Bugzilla::Extension::BMO::Data qw($cf_visible_in_products
%product_sec_groups);
use Bugzilla::Extension::BMO::Reports qw(user_activity_report
triage_reports
- group_admins);
+ group_admins
+ email_queue_report);
our $VERSION = '0.1';
@@ -169,6 +170,9 @@ sub page_before_template {
elsif ($page eq 'group_admins.html') {
group_admins($vars);
}
+ elsif ($page eq 'email_queue.html') {
+ email_queue_report($vars);
+ }
}
sub _get_field_values_sort_key {
diff --git a/extensions/BMO/lib/Reports.pm b/extensions/BMO/lib/Reports.pm
index 7dcbc0ae6..aa7ca5690 100644
--- a/extensions/BMO/lib/Reports.pm
+++ b/extensions/BMO/lib/Reports.pm
@@ -32,7 +32,8 @@ use base qw(Exporter);
our @EXPORT_OK = qw(user_activity_report
triage_reports
- group_admins);
+ group_admins
+ email_queue_report);
sub user_activity_report {
my ($vars) = @_;
@@ -560,4 +561,28 @@ sub group_admins {
$vars->{'groups'} = \@groups;
}
+sub email_queue_report {
+ my ($vars, $filter) = @_;
+ my $dbh = Bugzilla->dbh;
+ my $user = Bugzilla->user;
+
+ $user->in_group('admin')
+ || ThrowUserError('auth_failure', { group => 'admin',
+ action => 'run',
+ object => 'email_queue' });
+
+ my $query = "
+ SELECT j.jobid,
+ j.run_after AS timestamp,
+ COUNT(e.jobid) AS error_count,
+ MAX(e.error_time) AS error_time,
+ e.message AS error_message
+ FROM ts_job j
+ LEFT JOIN ts_error e ON e.jobid = j.jobid
+ GROUP BY j.jobid
+ ORDER BY j.run_after";
+
+ $vars->{'jobs'} = $dbh->selectall_arrayref($query, { Slice => {} });
+}
+
1;
diff --git a/extensions/BMO/template/en/default/hook/global/user-error-auth_failure_object.html.tmpl b/extensions/BMO/template/en/default/hook/global/user-error-auth_failure_object.html.tmpl
index 067347f3b..0a674aa30 100644
--- a/extensions/BMO/template/en/default/hook/global/user-error-auth_failure_object.html.tmpl
+++ b/extensions/BMO/template/en/default/hook/global/user-error-auth_failure_object.html.tmpl
@@ -1,3 +1,5 @@
[% IF object == 'group_admins' %]
the group administrators report
+[% ELSIF object == 'email_queue' %]
+ the email queue status report
[% END %]
diff --git a/extensions/BMO/template/en/default/hook/reports/menu-end.html.tmpl b/extensions/BMO/template/en/default/hook/reports/menu-end.html.tmpl
index 6e8463020..846f12767 100644
--- a/extensions/BMO/template/en/default/hook/reports/menu-end.html.tmpl
+++ b/extensions/BMO/template/en/default/hook/reports/menu-end.html.tmpl
@@ -36,6 +36,10 @@
<strong><a href="[% urlbase FILTER none
%]page.cgi?id=group_admins.html">Group Admins</a></strong> - Group Admins Report
</li>
+ <li>
+ <strong><a href="[% urlbase FILTER none
+ %]page.cgi?id=email_queue.html">Email Queue</a></strong> - TheSchwartz queue
+ </li>
[% END %]
</ul>
diff --git a/extensions/BMO/template/en/default/pages/email_queue.html.tmpl b/extensions/BMO/template/en/default/pages/email_queue.html.tmpl
new file mode 100644
index 000000000..7afd083ac
--- /dev/null
+++ b/extensions/BMO/template/en/default/pages/email_queue.html.tmpl
@@ -0,0 +1,53 @@
+[%# This Source Code Form is subject to the terms of the Mozilla Public
+ # License, v. 2.0. If a copy of the MPL was not distributed with this
+ # file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ #
+ # This Source Code Form is "Incompatible With Secondary Licenses", as
+ # defined by the Mozilla Public License, v. 2.0.
+ #%]
+
+[% INCLUDE global/header.html.tmpl
+ title = "Job Queue Status"
+ style_urls = [ "extensions/BMO/web/styles/reports.css" ]
+%]
+
+[% IF jobs.size %]
+
+ <p><i>[% jobs.size FILTER none %] email(s) in the queue.</i></p>
+
+ <table id="report" cellspacing="0" border="0">
+ <tr id="report-header">
+ <th>Time</th>
+ <th>Error Count</th>
+ <th>Last Error</th>
+ <th>Error Message</th>
+ </tr>
+ [% FOREACH job IN jobs %]
+ <tr class="report item [% loop.count % 2 == 1 ? "report_row_odd" : "report_row_even" %]">
+ <td nowrap>[% time2str("%Y-%m-%d %H:%M:%S %Z", job.timestamp) FILTER html %]</td>
+ <td nowrap>[% job.error_count FILTER html %]</td>
+ <td nowrap>
+ [% IF job.error_count %]
+ [% time2str("%Y-%m-%d %H:%M:%S %Z", job.error_time) FILTER html %]
+ [% ELSE %]
+ -
+ [% END %]
+ </td>
+ <td>
+ [% IF job.error_count %]
+ [% job.error_message FILTER html %]
+ [% ELSE %]
+ -
+ [% END %]
+ </td>
+ </tr>
+ [% END %]
+ </table>
+
+[% ELSE %]
+
+<p><i>The email queue is empty.</i></p>
+
+[% END %]
+
+[% INCLUDE global/footer.html.tmpl %]
diff --git a/extensions/BMO/web/styles/reports.css b/extensions/BMO/web/styles/reports.css
index 3106a6295..260a95471 100644
--- a/extensions/BMO/web/styles/reports.css
+++ b/extensions/BMO/web/styles/reports.css
@@ -2,10 +2,6 @@
display: none;
}
-#triage_form th {
- text-align: left;
-}
-
#product, #component {
width: 20em;
}
@@ -14,8 +10,12 @@
background: #ccccff;
}
-#report td {
- padding: 1px 10px 1px 10px;
+#report td, #report th {
+ padding: 3px 10px 3px 3px;
+}
+
+#report th {
+ text-align: left;
}
#report-header {
@@ -32,6 +32,6 @@
color: #000000;
}
-tr.report_item:hover {
+#report tr:hover {
background-color: #ccccff;
}