Defect #5371 » 5371.patch
| app/controllers/gantts_controller.rb | ||
|---|---|---|
|
@gantt = Redmine::Helpers::Gantt.new(params)
|
||
|
retrieve_query
|
||
|
@query.group_by = nil
|
||
|
if @query.valid?
|
||
|
events = []
|
||
|
# Issues that have start and due dates
|
||
|
events += @query.issues(:include => [:tracker, :assigned_to, :priority],
|
||
|
:order => "start_date, due_date",
|
||
|
: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]
|
||
|
)
|
||
|
# Issues that don't have a due date but that are assigned to a version with a date
|
||
|
events += @query.issues(:include => [:tracker, :assigned_to, :priority, :fixed_version],
|
||
|
:order => "start_date, effective_date",
|
||
|
: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]
|
||
|
)
|
||
|
# Versions
|
||
|
events += @query.versions(:conditions => ["effective_date BETWEEN ? AND ?", @gantt.date_from, @gantt.date_to])
|
||
|
|
||
|
@gantt.events = events
|
||
|
end
|
||
|
@gantt.fill_events_with_query(@query) if @query.valid?
|
||
|
|
||
|
basename = (@project ? "#{@project.identifier}-" : '') + 'gantt'
|
||
|
|
||
| lib/redmine/helpers/gantt.rb | ||
|---|---|---|
|
@date_from = Date.civil(@year_from, @month_from, 1)
|
||
|
@date_to = (@date_from >> @months) - 1
|
||
|
end
|
||
|
|
||
|
def fill_events_with_query(query)
|
||
|
events = []
|
||
|
# Issues that have start and due dates
|
||
|
events += query.issues(:include => [:tracker, :assigned_to, :priority],
|
||
|
:order => "#{Issue.quoted_table_name}.start_date, #{Issue.quoted_table_name}.due_date",
|
||
|
:conditions => conditions_for_issues_with_dates)
|
||
|
# Issues that don't have a due date but that are assigned to a version with a date
|
||
|
events += query.issues(:include => [:tracker, :assigned_to, :priority, :fixed_version],
|
||
|
:order => "#{Issue.quoted_table_name}.start_date, #{Version.quoted_table_name}.effective_date",
|
||
|
:conditions => conditions_for_issues_with_milestone_dates)
|
||
|
# Versions
|
||
|
events += query.versions(:conditions => ["#{Version.quoted_table_name}.effective_date BETWEEN ? AND ?", date_from, date_to])
|
||
|
self.events = events
|
||
|
end
|
||
|
|
||
|
def events=(e)
|
||
|
@events = e
|
||
| ... | ... | |
|
x.start_date <=> y.start_date
|
||
|
end
|
||
|
end
|
||
|
def conditions_for_issues_with_dates
|
||
|
[<<SQL, date_from, date_to, date_from, date_to, date_from, date_to]
|
||
|
(
|
||
|
(
|
||
|
(#{Issue.quoted_table_name}.start_date >= ? AND
|
||
|
#{Issue.quoted_table_name}.start_date <= ?)
|
||
|
OR
|
||
|
(#{Issue.quoted_table_name}.due_date >= ? AND
|
||
|
#{Issue.quoted_table_name}.due_date <= ?)
|
||
|
OR
|
||
|
(#{Issue.quoted_table_name}.start_date < ? AND
|
||
|
#{Issue.quoted_table_name}.due_date > ?)
|
||
|
)
|
||
|
AND
|
||
|
#{Issue.quoted_table_name}.start_date IS NOT NULL
|
||
|
AND
|
||
|
#{Issue.quoted_table_name}.due_date IS NOT NULL
|
||
|
)
|
||
|
SQL
|
||
|
end
|
||
|
def conditions_for_issues_with_milestone_dates
|
||
|
[<<SQL, date_from, date_to, date_from, date_to, date_from, date_to]
|
||
|
(
|
||
|
(
|
||
|
(
|
||
|
#{Issue.quoted_table_name}.start_date >= ?
|
||
|
AND
|
||
|
#{Issue.quoted_table_name}.start_date <= ?
|
||
|
)
|
||
|
OR
|
||
|
(
|
||
|
#{Version.quoted_table_name}.effective_date >= ?
|
||
|
AND
|
||
|
#{Version.quoted_table_name}.effective_date <= ?
|
||
|
)
|
||
|
OR
|
||
|
(
|
||
|
#{Issue.quoted_table_name}.start_date < ?
|
||
|
AND
|
||
|
#{Version.quoted_table_name}.effective_date > ?
|
||
|
)
|
||
|
)
|
||
|
AND
|
||
|
#{Issue.quoted_table_name}.start_date IS NOT NULL
|
||
|
AND
|
||
|
#{Issue.quoted_table_name}.due_date IS NULL
|
||
|
AND
|
||
|
#{Version.quoted_table_name}.effective_date IS NOT NULL
|
||
|
)
|
||
|
SQL
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
- « Previous
- 1
- 2
- Next »