Skip to content

Commit 6bf2ddd

Browse files
committed
Bug 1134765: Report for recruiting data
1 parent 18f29b2 commit 6bf2ddd

File tree

6 files changed

+178
-15
lines changed

6 files changed

+178
-15
lines changed

extensions/BMO/Extension.pm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@ sub page_before_template {
174174
require Bugzilla::Extension::BMO::Reports::Groups;
175175
Bugzilla::Extension::BMO::Reports::Groups::members_report($vars);
176176
}
177+
elsif ($page eq 'recruiting_dashboard.html') {
178+
require Bugzilla::Extension::BMO::Reports::Recruiting;
179+
Bugzilla::Extension::BMO::Reports::Recruiting::report($vars);
180+
}
177181
elsif ($page eq 'email_queue.html') {
178182
print Bugzilla->cgi->redirect('view_job_queue.cgi');
179183
}
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
4+
#
5+
# This Source Code Form is "Incompatible With Secondary Licenses", as
6+
# defined by the Mozilla Public License, v. 2.0.
7+
8+
package Bugzilla::Extension::BMO::Reports::Recruiting;
9+
use strict;
10+
use warnings;
11+
12+
use Bugzilla::Error;
13+
use Bugzilla::Bug;
14+
use Bugzilla::Product;
15+
16+
sub report {
17+
my ($vars) = @_;
18+
my $user = Bugzilla->user;
19+
20+
$user->in_group('hr')
21+
|| ThrowUserError('auth_failure', { group => 'hr',
22+
action => 'run',
23+
object => 'recruiting_dashboard' });
24+
25+
my $product = Bugzilla::Product->check({ name => 'Recruiting', cache => 1 });
26+
27+
# find all open recruiting bugs
28+
my $bugs = Bugzilla::Bug->match({
29+
product_id => $product->id,
30+
resolution => '',
31+
});
32+
33+
# filter bugs based on visibility and re-bless
34+
$user->visible_bugs($bugs);
35+
$bugs = [
36+
map { bless($_, 'RecuritingBug') }
37+
grep { $user->can_see_bug($_->id) }
38+
@$bugs
39+
];
40+
41+
$vars->{bugs} = $bugs;
42+
}
43+
44+
1;
45+
46+
package RecuritingBug;
47+
use strict;
48+
use warnings;
49+
50+
use base qw(Bugzilla::Bug);
51+
52+
use Bugzilla::Comment;
53+
use Bugzilla::Util qw(trim);
54+
55+
sub _extract {
56+
my ($self) = @_;
57+
return if exists $self->{recruitment_data};
58+
$self->{recruitment_data} = {};
59+
60+
# we only need the first comment
61+
my $comment = Bugzilla::Comment->match({
62+
bug_id => $self->id,
63+
LIMIT => 1,
64+
})->[0]->body;
65+
66+
# extract just what we need
67+
# changing the comment will break this
68+
69+
if ($comment =~ /\nHiring Manager:\s+(.+)VP Authority:\n/s) {
70+
$self->{recruitment_data}->{hiring_manager} = trim($1);
71+
}
72+
if ($comment =~ /\nVP Authority:\s+(.+)HRBP:\n/s) {
73+
$self->{recruitment_data}->{scvp} = trim($1);
74+
}
75+
if ($comment =~ /\nWhat part of your strategic plan does this role impact\?\s+(.+)Why is this critical for success\?\n/s) {
76+
$self->{recruitment_data}->{strategic_plan} = trim($1);
77+
}
78+
if ($comment =~ /\nWhy is this critical for success\?\s+(.+)$/s) {
79+
$self->{recruitment_data}->{why_critical} = trim($1);
80+
}
81+
}
82+
83+
sub hiring_manager {
84+
my ($self) = @_;
85+
$self->_extract();
86+
return $self->{recruitment_data}->{hiring_manager};
87+
}
88+
89+
sub scvp {
90+
my ($self) = @_;
91+
$self->_extract();
92+
return $self->{recruitment_data}->{scvp};
93+
}
94+
95+
sub strategic_plan {
96+
my ($self) = @_;
97+
$self->_extract();
98+
return $self->{recruitment_data}->{strategic_plan};
99+
}
100+
101+
sub why_critical {
102+
my ($self) = @_;
103+
$self->_extract();
104+
return $self->{recruitment_data}->{why_critical};
105+
}
106+
107+
1;

extensions/BMO/template/en/default/bug/create/comment-recruiting.txt.tmpl

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
1-
[%# The contents of this file are subject to the Mozilla Public
2-
# License Version 1.1 (the "License"); you may not use this file
3-
# except in compliance with the License. You may obtain a copy of
4-
# the License at http://www.mozilla.org/MPL/
1+
[%# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
54
#
6-
# Software distributed under the License is distributed on an "AS
7-
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
8-
# implied. See the License for the specific language governing
9-
# rights and limitations under the License.
10-
#
11-
# The Original Code is the BMO Bugzilla Extension.
5+
# This Source Code Form is "Incompatible With Secondary Licenses", as
6+
# defined by the Mozilla Public License, v. 2.0.
7+
#%]
8+
9+
[%#
10+
# IMPORTANT
1211
#
13-
# The Initial Developer of the Original Code is the Mozilla Foundation
14-
# Portions created by the Initial Developers are Copyright (C) 2011 the
15-
# Initial Developer. All Rights Reserved.
12+
# If you update this template, you must also update the parsing code in
13+
# extensions/BMO/lib/Reports/Recruiting.pm
1614
#
17-
# Contributor(s):
18-
# David Lawrence <dkl@mozilla.com>
1915
#%]
16+
2017
[% USE Bugzilla %]
2118
[% cgi = Bugzilla.cgi %]
2219

extensions/BMO/template/en/default/hook/global/user-error-auth_failure_object.html.tmpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@
1616
comments
1717
[% ELSIF object == 'bounty_attachments' %]
1818
bounty attachments
19+
[% ELSIF object == 'recruiting_dashboard' %]
20+
the Recruiting Dashboard
1921
[% END %]

extensions/BMO/template/en/default/hook/reports/menu-end.html.tmpl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,12 @@
5959
</strong> - TheSchwartz queue
6060
</li>
6161
[% END %]
62+
[% IF user.in_group('hr') %]
63+
<li>
64+
<strong>
65+
<a href="[% urlbase FILTER none %]page.cgi?id=recruiting_dashboard.html">Recruiting Dashboard</a>
66+
</strong> - Dashboard for open requested requisitions.
67+
</li>
68+
[% END %]
6269
</ul>
6370

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
[%# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
4+
#
5+
# This Source Code Form is "Incompatible With Secondary Licenses", as
6+
# defined by the Mozilla Public License, v. 2.0.
7+
#%]
8+
9+
[% PROCESS global/variables.none.tmpl %]
10+
[% INCLUDE global/header.html.tmpl
11+
title = "Recruiting Dashboard"
12+
style_urls = [ "extensions/BMO/web/styles/reports.css" ]
13+
style = "#report td { vertical-align: top; }"
14+
%]
15+
16+
<h1>Recuriting Dashboard</h1>
17+
18+
[% IF bugs.size %]
19+
<table border="0" cellspacing="0" id="report" class="hover" width="100%">
20+
<tr id="report-header">
21+
<th>[% terms.Bug %]</th>
22+
<th>Summary</th>
23+
<th>Hiring Manager</th>
24+
<th>SCVP</th>
25+
<th>Part of Strategic Plan</th>
26+
<th>Why is this critical for success</th>
27+
</tr>
28+
29+
[% FOREACH bug = bugs %]
30+
<tr class="report_item [% loop.count % 2 == 1 ? "report_row_odd" : "report_row_even" %]">
31+
<td>[% bug.id FILTER bug_link(bug) FILTER none %]</td>
32+
<td>[% bug.short_desc FILTER html %]</td>
33+
<td>[% bug.hiring_manager FILTER html %]</td>
34+
<td>[% bug.scvp FILTER html %]</td>
35+
<td>[% bug.strategic_plan FILTER html FILTER html_line_break %]</td>
36+
<td>[% bug.why_critical FILTER html FILTER html_line_break %]</td>
37+
</tr>
38+
[% END %]
39+
</table>
40+
[% ELSE %]
41+
<p>
42+
No open recruiting requisitions.
43+
</p>
44+
[% END %]
45+
46+
[% INCLUDE global/footer.html.tmpl %]

0 commit comments

Comments
 (0)