Feature #6375 » add_column_last_updated_by.patch
| app/models/issue.rb | ||
|---|---|---|
|
@spent_hours = nil
|
||
|
@total_spent_hours = nil
|
||
|
@total_estimated_hours = nil
|
||
|
@last_updated_by = nil
|
||
|
base_reload(*args)
|
||
|
end
|
||
| ... | ... | |
|
@relations ||= IssueRelation::Relations.new(self, (relations_from + relations_to).sort)
|
||
|
end
|
||
|
def last_updated_by
|
||
|
@last_updated_by
|
||
|
end
|
||
|
# Preloads relations for a collection of issues
|
||
|
def self.load_relations(issues)
|
||
|
if issues.any?
|
||
| ... | ... | |
|
end
|
||
|
end
|
||
|
# Preloads users who updated last a collection of issues
|
||
|
def self.load_last_updated_by(issues)
|
||
|
if issues.any?
|
||
|
journals_user = {}
|
||
|
issues_last_journal = Journal.joins(:issue).preload(:user).
|
||
|
where('issues.updated_on = journals.created_on').
|
||
|
where(:journalized_id => issues.map(&:id))
|
||
|
issues_last_journal.each do |journal|
|
||
|
journals_user[journal.journalized_id] = journal.user
|
||
|
end
|
||
|
issues.each do |issue|
|
||
|
issue.instance_variable_set "@last_updated_by", (journals_user[issue.id] || nil)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
# Finds an issue relation given its id.
|
||
|
def find_relation(relation_id)
|
||
|
IssueRelation.where("issue_to_id = ? OR issue_from_id = ?", id, id).find(relation_id)
|
||
| ... | ... | |
|
end
|
||
|
Project.where(condition).having_trackers
|
||
|
end
|
||
|
|
||
|
# Returns a scope of trackers that user can assign the issue to
|
||
|
def allowed_target_trackers(user=User.current)
|
||
|
self.class.allowed_target_trackers(project, user, tracker_id_was)
|
||
| app/models/issue_query.rb | ||
|---|---|---|
|
QueryColumn.new(:author, :sortable => lambda {User.fields_for_order_statement("authors")}, :groupable => true),
|
||
|
QueryColumn.new(:assigned_to, :sortable => lambda {User.fields_for_order_statement}, :groupable => true),
|
||
|
QueryColumn.new(:updated_on, :sortable => "#{Issue.table_name}.updated_on", :default_order => 'desc'),
|
||
|
QueryColumn.new(:last_updated_by, :sortable => false),
|
||
|
QueryColumn.new(:category, :sortable => "#{IssueCategory.table_name}.name", :groupable => true),
|
||
|
QueryColumn.new(:fixed_version, :sortable => lambda {Version.fields_for_order_statement}, :groupable => true),
|
||
|
QueryColumn.new(:start_date, :sortable => "#{Issue.table_name}.start_date"),
|
||
| ... | ... | |
|
QueryColumn.new(:created_on, :sortable => "#{Issue.table_name}.created_on", :default_order => 'desc'),
|
||
|
QueryColumn.new(:closed_on, :sortable => "#{Issue.table_name}.closed_on", :default_order => 'desc'),
|
||
|
QueryColumn.new(:relations, :caption => :label_related_issues),
|
||
|
QueryColumn.new(:description, :inline => false)
|
||
|
QueryColumn.new(:description, :inline => false),
|
||
|
]
|
||
|
def initialize(attributes=nil, *args)
|
||
| ... | ... | |
|
if has_column?(:total_spent_hours)
|
||
|
Issue.load_visible_total_spent_hours(issues)
|
||
|
end
|
||
|
if has_column?(:last_updated_by)
|
||
|
Issue.load_last_updated_by(issues)
|
||
|
end
|
||
|
if has_column?(:relations)
|
||
|
Issue.load_visible_relations(issues)
|
||
|
end
|
||