Feature #20458 » fetch_many_authors.patch
| lib/redmine/activity/fetcher.rb (cópia de trabalho) | ||
|---|---|---|
| 83 | 83 |
# Returns an array of events for the given date range |
| 84 | 84 |
# sorted in reverse chronological order |
| 85 | 85 |
def events(from = nil, to = nil, options={})
|
| 86 |
e = [] |
|
| 86 | ||
| 87 | 87 |
@options[:limit] = options[:limit] |
| 88 | 88 | |
| 89 |
@scope.each do |event_type|
|
|
| 90 |
constantized_providers(event_type).each do |provider|
|
|
| 91 |
e += provider.find_events(event_type, @user, from, to, @options)
|
|
| 92 |
end
|
|
| 89 |
if @options[:author].is_a? Array
|
|
| 90 |
e = @options[:author].map { |a| find_events_with_author(from, to, a) }.inject([], :+)
|
|
| 91 |
else
|
|
| 92 |
e = find_events_with_author(from, to, @options[:author])
|
|
| 93 | 93 |
end |
| 94 | 94 | |
| 95 | 95 |
e.sort! {|a,b| b.event_datetime <=> a.event_datetime}
|
| ... | ... | |
| 102 | 102 | |
| 103 | 103 |
private |
| 104 | 104 | |
| 105 |
def find_events_with_author(from, to, author) |
|
| 106 |
e = [] |
|
| 107 |
@scope.each do |event_type| |
|
| 108 |
constantized_providers(event_type).each do |provider| |
|
| 109 |
e += provider.find_events(event_type, @user, from, to, @options.merge(author: author)) |
|
| 110 |
end |
|
| 111 |
end |
|
| 112 |
e |
|
| 113 |
end |
|
| 114 | ||
| 105 | 115 |
def constantized_providers(event_type) |
| 106 | 116 |
Redmine::Activity.providers[event_type].map(&:constantize) |
| 107 | 117 |
end |