Defect #5371 » 5371.patch
app/controllers/gantts_controller.rb | ||
---|---|---|
15 | 15 |
@gantt = Redmine::Helpers::Gantt.new(params) |
16 | 16 |
retrieve_query |
17 | 17 |
@query.group_by = nil |
18 |
if @query.valid? |
|
19 |
events = [] |
|
20 |
# Issues that have start and due dates |
|
21 |
events += @query.issues(:include => [:tracker, :assigned_to, :priority], |
|
22 |
:order => "start_date, due_date", |
|
23 |
:conditions => ["(((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?) or (start_date<? and due_date>?)) and start_date is not null and due_date is not null)", @gantt.date_from, @gantt.date_to, @gantt.date_from, @gantt.date_to, @gantt.date_from, @gantt.date_to] |
|
24 |
) |
|
25 |
# Issues that don't have a due date but that are assigned to a version with a date |
|
26 |
events += @query.issues(:include => [:tracker, :assigned_to, :priority, :fixed_version], |
|
27 |
:order => "start_date, effective_date", |
|
28 |
:conditions => ["(((start_date>=? and start_date<=?) or (effective_date>=? and effective_date<=?) or (start_date<? and effective_date>?)) and start_date is not null and due_date is null and effective_date is not null)", @gantt.date_from, @gantt.date_to, @gantt.date_from, @gantt.date_to, @gantt.date_from, @gantt.date_to] |
|
29 |
) |
|
30 |
# Versions |
|
31 |
events += @query.versions(:conditions => ["effective_date BETWEEN ? AND ?", @gantt.date_from, @gantt.date_to]) |
|
32 |
|
|
33 |
@gantt.events = events |
|
34 |
end |
|
18 |
@gantt.fill_events_with_query(@query) if @query.valid? |
|
35 | 19 |
|
36 | 20 |
basename = (@project ? "#{@project.identifier}-" : '') + 'gantt' |
37 | 21 |
|
lib/redmine/helpers/gantt.rb | ||
---|---|---|
51 | 51 |
@date_from = Date.civil(@year_from, @month_from, 1) |
52 | 52 |
@date_to = (@date_from >> @months) - 1 |
53 | 53 |
end |
54 |
|
|
54 | ||
55 |
def fill_events_with_query(query) |
|
56 |
events = [] |
|
57 |
# Issues that have start and due dates |
|
58 |
events += query.issues(:include => [:tracker, :assigned_to, :priority], |
|
59 |
:order => "#{Issue.quoted_table_name}.start_date, #{Issue.quoted_table_name}.due_date", |
|
60 |
:conditions => conditions_for_issues_with_dates) |
|
61 | ||
62 |
# Issues that don't have a due date but that are assigned to a version with a date |
|
63 |
events += query.issues(:include => [:tracker, :assigned_to, :priority, :fixed_version], |
|
64 |
:order => "#{Issue.quoted_table_name}.start_date, #{Version.quoted_table_name}.effective_date", |
|
65 |
:conditions => conditions_for_issues_with_milestone_dates) |
|
66 | ||
67 |
# Versions |
|
68 |
events += query.versions(:conditions => ["#{Version.quoted_table_name}.effective_date BETWEEN ? AND ?", date_from, date_to]) |
|
69 | ||
70 |
self.events = events |
|
71 |
end |
|
55 | 72 |
|
56 | 73 |
def events=(e) |
57 | 74 |
@events = e |
... | ... | |
269 | 286 |
x.start_date <=> y.start_date |
270 | 287 |
end |
271 | 288 |
end |
289 | ||
290 |
def conditions_for_issues_with_dates |
|
291 |
[<<SQL, date_from, date_to, date_from, date_to, date_from, date_to] |
|
292 |
( |
|
293 |
( |
|
294 |
(#{Issue.quoted_table_name}.start_date >= ? AND |
|
295 |
#{Issue.quoted_table_name}.start_date <= ?) |
|
296 |
OR |
|
297 |
(#{Issue.quoted_table_name}.due_date >= ? AND |
|
298 |
#{Issue.quoted_table_name}.due_date <= ?) |
|
299 |
OR |
|
300 |
(#{Issue.quoted_table_name}.start_date < ? AND |
|
301 |
#{Issue.quoted_table_name}.due_date > ?) |
|
302 |
) |
|
303 |
AND |
|
304 |
#{Issue.quoted_table_name}.start_date IS NOT NULL |
|
305 |
AND |
|
306 |
#{Issue.quoted_table_name}.due_date IS NOT NULL |
|
307 |
) |
|
308 |
SQL |
|
309 |
end |
|
310 | ||
311 |
def conditions_for_issues_with_milestone_dates |
|
312 |
[<<SQL, date_from, date_to, date_from, date_to, date_from, date_to] |
|
313 |
( |
|
314 |
( |
|
315 |
( |
|
316 |
#{Issue.quoted_table_name}.start_date >= ? |
|
317 |
AND |
|
318 |
#{Issue.quoted_table_name}.start_date <= ? |
|
319 |
) |
|
320 |
OR |
|
321 |
( |
|
322 |
#{Version.quoted_table_name}.effective_date >= ? |
|
323 |
AND |
|
324 |
#{Version.quoted_table_name}.effective_date <= ? |
|
325 |
) |
|
326 |
OR |
|
327 |
( |
|
328 |
#{Issue.quoted_table_name}.start_date < ? |
|
329 |
AND |
|
330 |
#{Version.quoted_table_name}.effective_date > ? |
|
331 |
) |
|
332 |
) |
|
333 |
AND |
|
334 |
#{Issue.quoted_table_name}.start_date IS NOT NULL |
|
335 |
AND |
|
336 |
#{Issue.quoted_table_name}.due_date IS NULL |
|
337 |
AND |
|
338 |
#{Version.quoted_table_name}.effective_date IS NOT NULL |
|
339 |
) |
|
340 |
SQL |
|
341 |
end |
|
272 | 342 |
end |
273 | 343 |
end |
274 | 344 |
end |
- « Previous
- 1
- 2
- Next »