Skip to content

Commit d78003b

Browse files
committed
Bug 1245471 - Release Tracking Report should be able to have custom dates
1 parent 4cdd5e5 commit d78003b

File tree

3 files changed

+251
-68
lines changed

3 files changed

+251
-68
lines changed

extensions/BMO/lib/Reports/ReleaseTracking.pm

Lines changed: 172 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,173 @@ use Bugzilla::Error;
1414
use Bugzilla::Extension::BMO::Util;
1515
use Bugzilla::Field;
1616
use Bugzilla::FlagType;
17-
use Bugzilla::Util qw(correct_urlbase trick_taint);
17+
use Bugzilla::Util qw(correct_urlbase trick_taint validate_date);
1818
use JSON qw(-convert_blessed_universally);
1919
use List::MoreUtils qw(uniq);
2020

21+
use constant DATE_RANGES => [
22+
{
23+
value => '20160126-20160307',
24+
label => '2016-01-26 and 2016-03-07'
25+
},
26+
{
27+
value => '20151215-20160125',
28+
label => '2015-12-15 and 2016-01-25'
29+
},
30+
{
31+
value => '20151103-20151214',
32+
label => '2015-11-03 and 2015-12-14'
33+
},
34+
{
35+
value => '20150922-20151102',
36+
label => '2015-09-22 and 2015-11-02'
37+
},
38+
{
39+
value => '20150811-20150921',
40+
label => '2015-08-11 and 2015-09-21'
41+
},
42+
{
43+
value => '20150630-20150810',
44+
label => '2015-06-30 and 2015-08-10'
45+
},
46+
{
47+
value => '20150512-20150629',
48+
label => '2015-05-12 and 2015-06-29'
49+
},
50+
{
51+
value => '20150331-20150511',
52+
label => '2015-03-31 and 2015-05-11'
53+
},
54+
{
55+
value => '20150224-20150330',
56+
label => '2015-02-24 and 2015-03-30'
57+
},
58+
{
59+
value => '20150113-20150223',
60+
label => '2015-01-13 and 2015-02-23'
61+
},
62+
{
63+
value => '20141111-20141222',
64+
label => '2014-11-11 and 2014-12-22'
65+
},
66+
{
67+
value => '20140930-20141110',
68+
label => '2014-09-30 and 2014-11-10'
69+
},
70+
{
71+
value => '20140819-20140929',
72+
label => '2014-08-19 and 2014-09-29'
73+
},
74+
{
75+
value => '20140708-20140818',
76+
label => '2014-07-08 and 2014-08-18'
77+
},
78+
{
79+
value => '20140527-20140707',
80+
label => '2014-05-27 and 2014-07-07'
81+
},
82+
{
83+
value => '20140415-20140526',
84+
label => '2014-04-15 and 2014-05-26'
85+
},
86+
{
87+
value => '20140304-20140414',
88+
label => '2014-03-04 and 2014-04-14'
89+
},
90+
{
91+
value => '20140121-20140303',
92+
label => '2014-01-21 and 2014-03-03'
93+
},
94+
{
95+
value => '20131210-20140120',
96+
label => '2013-12-10 and 2014-01-20'
97+
},
98+
{
99+
value => '20131029-20131209',
100+
label => '2013-10-29 and 2013-12-09'
101+
},
102+
{
103+
value => '20130917-20131028',
104+
label => '2013-09-17 and 2013-10-28'
105+
},
106+
{
107+
value => '20130806-20130916',
108+
label => '2013-08-06 and 2013-09-16'
109+
},
110+
{
111+
value => '20130625-20130805',
112+
label => '2013-06-25 and 2013-08-05'
113+
},
114+
{
115+
value => '20130514-20130624',
116+
label => '2013-05-14 and 2013-06-24'
117+
},
118+
{
119+
value => '20130402-20130513',
120+
label => '2013-04-02 and 2013-05-13'
121+
},
122+
{
123+
value => '20130219-20130401',
124+
label => '2013-02-19 and 2013-04-01'
125+
},
126+
{
127+
value => '20130108-20130218',
128+
label => '2013-01-08 and 2013-02-18'
129+
},
130+
{
131+
value => '20121120-20130107',
132+
label => '2012-11-20 and 2013-01-07'
133+
},
134+
{
135+
value => '20121009-20121119',
136+
label => '2012-10-09 and 2012-11-19'
137+
},
138+
{
139+
value => '20120828-20121008',
140+
label => '2012-08-28 and 2012-10-08'
141+
},
142+
{
143+
value => '20120717-20120827',
144+
label => '2012-07-17 and 2012-08-27'
145+
},
146+
{
147+
value => '20120605-20120716',
148+
label => '2012-06-05 and 2012-07-16'
149+
},
150+
{
151+
value => '20120424-20120604',
152+
label => '2012-04-24 and 2012-06-04'
153+
},
154+
{
155+
value => '20120313-20120423',
156+
label => '2012-03-13 and 2012-04-23'
157+
},
158+
{
159+
value => '20120131-20120312',
160+
label => '2012-01-31 and 2012-03-12'
161+
},
162+
{
163+
value => '20111220-20120130',
164+
label => '2011-12-20 and 2012-01-30'
165+
},
166+
{
167+
value => '20111108-20111219',
168+
label => '2011-11-08 and 2011-12-19'
169+
},
170+
{
171+
value => '20110927-20111107',
172+
label => '2011-09-27 and 2011-11-07'
173+
},
174+
{
175+
value => '20110816-20110926',
176+
label => '2011-08-16 and 2011-09-26'
177+
},
178+
{
179+
value => '*',
180+
label => 'Anytime'
181+
}
182+
];
183+
21184
sub report {
22185
my ($vars) = @_;
23186
my $dbh = Bugzilla->dbh;
@@ -180,55 +343,6 @@ sub report {
180343
}
181344
}
182345

183-
#
184-
# rapid release dates
185-
#
186-
187-
my @ranges;
188-
my $start_date = string_to_datetime('2011-08-16');
189-
my $end_date = $start_date->clone->add(weeks => 6)->add(days => -1);
190-
my $now_date = string_to_datetime('2012-11-19');
191-
192-
while ($start_date <= $now_date) {
193-
unshift @ranges, {
194-
value => sprintf("%s-%s", $start_date->ymd(''), $end_date->ymd('')),
195-
label => sprintf("%s and %s", $start_date->ymd('-'), $end_date->ymd('-')),
196-
};
197-
198-
$start_date = $end_date->clone;;
199-
$start_date->add(days => 1);
200-
$end_date->add(weeks => 6);
201-
}
202-
203-
# 2012-11-20 - 2013-01-06 was a 7 week release cycle instead of 6
204-
$start_date = string_to_datetime('2012-11-20');
205-
$end_date = $start_date->clone->add(weeks => 7)->add(days => -1);
206-
unshift @ranges, {
207-
value => sprintf("%s-%s", $start_date->ymd(''), $end_date->ymd('')),
208-
label => sprintf("%s and %s", $start_date->ymd('-'), $end_date->ymd('-')),
209-
};
210-
211-
# Back on track with 6 week releases
212-
$start_date = string_to_datetime('2013-01-08');
213-
$end_date = $start_date->clone->add(weeks => 6)->add(days => -1);
214-
$now_date = time_to_datetime((time));
215-
216-
while ($start_date <= $now_date) {
217-
unshift @ranges, {
218-
value => sprintf("%s-%s", $start_date->ymd(''), $end_date->ymd('')),
219-
label => sprintf("%s and %s", $start_date->ymd('-'), $end_date->ymd('-')),
220-
};
221-
222-
$start_date = $end_date->clone;;
223-
$start_date->add(days => 1);
224-
$end_date->add(weeks => 6);
225-
}
226-
227-
push @ranges, {
228-
value => '*',
229-
label => 'Anytime',
230-
};
231-
232346
#
233347
# run report
234348
#
@@ -335,8 +449,9 @@ sub report {
335449
$vars->{products_json} = $json->encode(\@products_json);
336450
$vars->{fields_json} = $json->encode(\@fields_json);
337451
$vars->{flag_names} = \@flag_names;
338-
$vars->{ranges} = \@ranges;
452+
$vars->{ranges} = DATE_RANGES;
339453
$vars->{default_query} = $input->{q};
454+
$vars->{is_custom} = $input->{is_custom};
340455
foreach my $field (qw(product flags range)) {
341456
$vars->{$field} = $input->{$field};
342457
}
@@ -370,6 +485,12 @@ sub _parse_query {
370485
or ThrowUserError('report_invalid_parameter', { name => 'date_range' });
371486
$query->{start_date} = "$1-$2-$3";
372487
$query->{end_date} = "$4-$5-$6";
488+
validate_date($query->{start_date})
489+
|| ThrowUserError('illegal_date', { date => $query->{start_date},
490+
format => 'YYYY-MM-DD' });
491+
validate_date($query->{end_date})
492+
|| ThrowUserError('illegal_date', { date => $query->{end_date},
493+
format => 'YYYY-MM-DD' });
373494
}
374495

375496
# product_id

extensions/BMO/template/en/default/pages/release_tracking_report.html.tmpl

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88

99
[% INCLUDE global/header.html.tmpl
1010
title = "Release Tracking Report"
11-
style_urls = [ "extensions/BMO/web/styles/reports.css" ]
11+
style_urls = [ "extensions/BMO/web/styles/reports.css",
12+
"js/jquery/plugins/datetimepicker/datetimepicker.css" ]
1213
javascript_urls = [ "extensions/BMO/web/js/release_tracking_report.js" ]
14+
jquery = [ "datetimepicker" ]
1315
%]
1416

1517
<noscript>
@@ -39,20 +41,31 @@ var default_query = '[% default_query FILTER js %]';
3941
</select>
4042

4143
was changed to (and is currently)
42-
<select id="flag_value">
44+
<select id="flag_value" onchange="serialiseForm()">
4345
<option value="?">?</option>
4446
<option value="-">-</option>
4547
<option value="+">+</option>
4648
</select>
4749

4850
between
49-
<select id="range" onChange="serialiseForm()">
50-
[% FOREACH range = ranges %]
51-
<option value="[% range.value FILTER html %]">
52-
[% range.label FILTER html %]
53-
</option>
54-
[% END %]
55-
</select>
51+
<span id="fixed_range">
52+
<select id="range" onChange="serialiseForm()">
53+
[% FOREACH range = ranges %]
54+
<option value="[% range.value FILTER html %]">
55+
[% range.label FILTER html %]
56+
</option>
57+
[% END %]
58+
</select>
59+
</span>
60+
<span id="custom_range" style="display:none;">
61+
<input class="date_field" name="from" id="from" onChange="serialiseForm()">
62+
<img class="date_field-img" id="from-img" src="extensions/BugModal/web/calendar.png" width="16" height="16">
63+
and
64+
<input class="date_field" name="to" id="to" onChange="serialiseForm()">
65+
<img class="date_field-img" id="to-img" src="extensions/BugModal/web/calendar.png" width="16" height="16">
66+
</span>
67+
<input type="checkbox" id="is_custom" onchange="selectRangeType()" [% "checked" IF is_custom %]>
68+
<label for="is_custom">Custom</label>
5669
</td>
5770
</tr>
5871

0 commit comments

Comments
 (0)