Feature #23954 » last_activity-3.r3.3.patch
app/controllers/admin_controller.rb | ||
---|---|---|
36 | 36 |
scope = scope.like(params[:name]) if params[:name].present? |
37 | 37 |
@projects = scope.to_a |
38 | 38 | |
39 |
@last_activity = Redmine::Activity::Fetcher.new(User.current).events(nil, nil, :last_by_project => true).to_h |
|
40 | ||
39 | 41 |
render :action => "projects", :layout => false if request.xhr? |
40 | 42 |
end |
41 | 43 |
app/views/admin/projects.html.erb | ||
---|---|---|
22 | 22 |
<th><%=l(:label_project)%></th> |
23 | 23 |
<th><%=l(:field_is_public)%></th> |
24 | 24 |
<th><%=l(:field_created_on)%></th> |
25 |
<th><%=l(:field_last_activity)%></th> |
|
25 | 26 |
<th></th> |
26 | 27 |
</tr></thead> |
27 | 28 |
<tbody> |
... | ... | |
30 | 31 |
<td class="name"><span><%= link_to_project_settings(project, {}, :title => project.short_description) %></span></td> |
31 | 32 |
<td><%= checked_image project.is_public? %></td> |
32 | 33 |
<td><%= format_date(project.created_on) %></td> |
34 |
<td><%= format_date(@last_activity[project.id]) %></td> |
|
33 | 35 |
<td class="buttons"> |
34 | 36 |
<%= link_to(l(:button_archive), archive_project_path(project, :status => params[:status]), :data => {:confirm => l(:text_are_you_sure)}, :method => :post, :class => 'icon icon-lock') unless project.archived? %> |
35 | 37 |
<%= link_to(l(:button_unarchive), unarchive_project_path(project, :status => params[:status]), :method => :post, :class => 'icon icon-unlock') if project.archived? && (project.parent.nil? || !project.parent.archived?) %> |
config/locales/en.yml | ||
---|---|---|
254 | 254 |
field_downloads: Downloads |
255 | 255 |
field_author: Author |
256 | 256 |
field_created_on: Created |
257 |
field_last_activity: Last activity |
|
257 | 258 |
field_updated_on: Updated |
258 | 259 |
field_closed_on: Closed |
259 | 260 |
field_field_format: Format |
config/locales/pt-BR.yml | ||
---|---|---|
222 | 222 |
field_downloads: Downloads |
223 | 223 |
field_author: Autor |
224 | 224 |
field_created_on: Criado em |
225 |
field_last_activity: Última atividade |
|
225 | 226 |
field_updated_on: Alterado em |
226 | 227 |
field_field_format: Formato |
227 | 228 |
field_is_for_all: Para todos os projetos |
lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb | ||
---|---|---|
55 | 55 | |
56 | 56 |
scope = (provider_options[:scope] || self) |
57 | 57 | |
58 |
if from && to |
|
59 |
scope = scope.where("#{provider_options[:timestamp]} BETWEEN ? AND ?", from, to) |
|
60 |
end |
|
58 |
scope = scope.where("#{provider_options[:timestamp]} >= ?", from) if from |
|
59 |
scope = scope.where("#{provider_options[:timestamp]} <= ?", to) if to |
|
61 | 60 | |
62 | 61 |
if options[:author] |
63 | 62 |
return [] if provider_options[:author_key].nil? |
... | ... | |
78 | 77 |
scope = scope.where(Project.allowed_to_condition(user, "view_#{self.name.underscore.pluralize}".to_sym, options)) |
79 | 78 |
end |
80 | 79 | |
80 |
if options[:next_by_project] |
|
81 |
scope = scope.group("projects.id").minimum(provider_options[:timestamp]) |
|
82 |
end |
|
83 | ||
84 |
if options[:last_by_project] |
|
85 |
scope = scope.group("projects.id").maximum(provider_options[:timestamp]) |
|
86 |
end |
|
87 | ||
81 | 88 |
scope.to_a |
82 | 89 |
end |
83 | 90 |
end |
lib/redmine/activity/fetcher.rb | ||
---|---|---|
85 | 85 |
def events(from = nil, to = nil, options={}) |
86 | 86 |
e = [] |
87 | 87 |
@options[:limit] = options[:limit] |
88 |
@options[:last_by_project] = options[:last_by_project] if options[:last_by_project] |
|
89 |
@options[:next_by_project] = options[:next_by_project] if options[:next_by_project] |
|
88 | 90 | |
89 | 91 |
@scope.each do |event_type| |
90 | 92 |
constantized_providers(event_type).each do |provider| |
... | ... | |
92 | 94 |
end |
93 | 95 |
end |
94 | 96 | |
95 |
e.sort! {|a,b| b.event_datetime <=> a.event_datetime} |
|
97 |
if options[:last_by_project] |
|
98 |
e.sort! |
|
99 |
elsif options[:next_by_project] |
|
100 |
e.sort! {|a,b| b <=> a} |
|
101 |
else |
|
102 |
e.sort! {|a,b| b.event_datetime <=> a.event_datetime} |
|
96 | 103 | |
97 |
if options[:limit] |
|
98 |
e = e.slice(0, options[:limit]) |
|
104 |
if options[:limit] |
|
105 |
e = e.slice(0, options[:limit]) |
|
106 |
end |
|
99 | 107 |
end |
100 | 108 |
e |
101 | 109 |
end |