@@ -14,10 +14,173 @@ use Bugzilla::Error;
14
14
use Bugzilla::Extension::BMO::Util;
15
15
use Bugzilla::Field;
16
16
use Bugzilla::FlagType;
17
- use Bugzilla::Util qw( correct_urlbase trick_taint) ;
17
+ use Bugzilla::Util qw( correct_urlbase trick_taint validate_date ) ;
18
18
use JSON qw( -convert_blessed_universally) ;
19
19
use List::MoreUtils qw( uniq) ;
20
20
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
+
21
184
sub report {
22
185
my ($vars ) = @_ ;
23
186
my $dbh = Bugzilla-> dbh;
@@ -180,55 +343,6 @@ sub report {
180
343
}
181
344
}
182
345
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
-
232
346
#
233
347
# run report
234
348
#
@@ -335,8 +449,9 @@ sub report {
335
449
$vars -> {products_json } = $json -> encode(\@products_json );
336
450
$vars -> {fields_json } = $json -> encode(\@fields_json );
337
451
$vars -> {flag_names } = \@flag_names ;
338
- $vars -> {ranges } = \ @ranges ;
452
+ $vars -> {ranges } = DATE_RANGES ;
339
453
$vars -> {default_query } = $input -> {q };
454
+ $vars -> {is_custom } = $input -> {is_custom };
340
455
foreach my $field (qw( product flags range) ) {
341
456
$vars -> {$field } = $input -> {$field };
342
457
}
@@ -370,6 +485,12 @@ sub _parse_query {
370
485
or ThrowUserError(' report_invalid_parameter' , { name => ' date_range' });
371
486
$query -> {start_date } = " $1 -$2 -$3 " ;
372
487
$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' });
373
494
}
374
495
375
496
# product_id
0 commit comments