Feature #6375 » add_column_last_updated_by.patch
| app/models/issue.rb | ||
|---|---|---|
| 244 | 244 |
@spent_hours = nil |
| 245 | 245 |
@total_spent_hours = nil |
| 246 | 246 |
@total_estimated_hours = nil |
| 247 |
@last_updated_by = nil |
|
| 247 | 248 |
base_reload(*args) |
| 248 | 249 |
end |
| 249 | 250 | |
| ... | ... | |
| 1027 | 1028 |
@relations ||= IssueRelation::Relations.new(self, (relations_from + relations_to).sort) |
| 1028 | 1029 |
end |
| 1029 | 1030 | |
| 1031 |
def last_updated_by |
|
| 1032 |
@last_updated_by |
|
| 1033 |
end |
|
| 1034 | ||
| 1030 | 1035 |
# Preloads relations for a collection of issues |
| 1031 | 1036 |
def self.load_relations(issues) |
| 1032 | 1037 |
if issues.any? |
| ... | ... | |
| 1081 | 1086 |
end |
| 1082 | 1087 |
end |
| 1083 | 1088 | |
| 1089 |
# Preloads users who updated last a collection of issues |
|
| 1090 |
def self.load_last_updated_by(issues) |
|
| 1091 |
if issues.any? |
|
| 1092 |
journals_user = {}
|
|
| 1093 |
issues_last_journal = Journal.joins(:issue).preload(:user). |
|
| 1094 |
where('issues.updated_on = journals.created_on').
|
|
| 1095 |
where(:journalized_id => issues.map(&:id)) |
|
| 1096 | ||
| 1097 |
issues_last_journal.each do |journal| |
|
| 1098 |
journals_user[journal.journalized_id] = journal.user |
|
| 1099 |
end |
|
| 1100 | ||
| 1101 |
issues.each do |issue| |
|
| 1102 |
issue.instance_variable_set "@last_updated_by", (journals_user[issue.id] || nil) |
|
| 1103 |
end |
|
| 1104 |
end |
|
| 1105 |
end |
|
| 1106 | ||
| 1084 | 1107 |
# Finds an issue relation given its id. |
| 1085 | 1108 |
def find_relation(relation_id) |
| 1086 | 1109 |
IssueRelation.where("issue_to_id = ? OR issue_from_id = ?", id, id).find(relation_id)
|
| ... | ... | |
| 1400 | 1423 |
end |
| 1401 | 1424 |
Project.where(condition).having_trackers |
| 1402 | 1425 |
end |
| 1403 |
|
|
| 1426 | ||
| 1404 | 1427 |
# Returns a scope of trackers that user can assign the issue to |
| 1405 | 1428 |
def allowed_target_trackers(user=User.current) |
| 1406 | 1429 |
self.class.allowed_target_trackers(project, user, tracker_id_was) |
| app/models/issue_query.rb | ||
|---|---|---|
| 31 | 31 |
QueryColumn.new(:author, :sortable => lambda {User.fields_for_order_statement("authors")}, :groupable => true),
|
| 32 | 32 |
QueryColumn.new(:assigned_to, :sortable => lambda {User.fields_for_order_statement}, :groupable => true),
|
| 33 | 33 |
QueryColumn.new(:updated_on, :sortable => "#{Issue.table_name}.updated_on", :default_order => 'desc'),
|
| 34 |
QueryColumn.new(:last_updated_by, :sortable => false), |
|
| 34 | 35 |
QueryColumn.new(:category, :sortable => "#{IssueCategory.table_name}.name", :groupable => true),
|
| 35 | 36 |
QueryColumn.new(:fixed_version, :sortable => lambda {Version.fields_for_order_statement}, :groupable => true),
|
| 36 | 37 |
QueryColumn.new(:start_date, :sortable => "#{Issue.table_name}.start_date"),
|
| ... | ... | |
| 44 | 45 |
QueryColumn.new(:created_on, :sortable => "#{Issue.table_name}.created_on", :default_order => 'desc'),
|
| 45 | 46 |
QueryColumn.new(:closed_on, :sortable => "#{Issue.table_name}.closed_on", :default_order => 'desc'),
|
| 46 | 47 |
QueryColumn.new(:relations, :caption => :label_related_issues), |
| 47 |
QueryColumn.new(:description, :inline => false) |
|
| 48 |
QueryColumn.new(:description, :inline => false),
|
|
| 48 | 49 |
] |
| 49 | 50 | |
| 50 | 51 |
def initialize(attributes=nil, *args) |
| ... | ... | |
| 328 | 329 |
if has_column?(:total_spent_hours) |
| 329 | 330 |
Issue.load_visible_total_spent_hours(issues) |
| 330 | 331 |
end |
| 332 |
if has_column?(:last_updated_by) |
|
| 333 |
Issue.load_last_updated_by(issues) |
|
| 334 |
end |
|
| 331 | 335 |
if has_column?(:relations) |
| 332 | 336 |
Issue.load_visible_relations(issues) |
| 333 | 337 |
end |