Project

General

Profile

Feature #23954 » last_activity-2.r3.4.patch

Performance patch for Redmine 3.4 - Frederico Camara, 2018-03-08 18:53

View differences:

app/helpers/admin_helper.rb
[l(:project_status_archived), '9']], selected.to_s)
end
def last_activities()
Redmine::Activity::Fetcher.new(User.current).events(nil, nil, :last_by_project => true).to_h
end
def plugin_data_for_updates(plugins)
data = {"v" => Redmine::VERSION.to_s, "p" => {}}
plugins.each do |plugin|
app/views/admin/projects.html.erb
<th><%=l(:label_project)%></th>
<th><%=l(:field_is_public)%></th>
<th><%=l(:field_created_on)%></th>
<th><%=l(:field_last_activity)%></th>
<th></th>
</tr></thead>
<tbody>
<% project_activities = last_activities %>
<% project_tree(@projects, :init_level => true) do |project, level| %>
<tr class="<%= project.css_classes %> <%= level > 0 ? "idnt idnt-#{level}" : nil %>">
<td class="name"><span><%= link_to_project_settings(project, {}, :title => project.short_description) %></span></td>
<td><%= checked_image project.is_public? %></td>
<td><%= format_date(project.created_on) %></td>
<td><%= format_date(project_activities[project.id]) %></td>
<td class="buttons">
<%= 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? %>
<%= 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
field_downloads: Downloads
field_author: Author
field_created_on: Created
field_last_activity: Last activity
field_updated_on: Updated
field_closed_on: Closed
field_field_format: Format
config/locales/pt-BR.yml
field_downloads: Downloads
field_author: Autor
field_created_on: Criado em
field_last_activity: Última atividade
field_updated_on: Alterado em
field_field_format: Formato
field_is_for_all: Para todos os projetos
lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb
scope = scope.where(Project.allowed_to_condition(user, "view_#{self.name.underscore.pluralize}".to_sym, options))
end
if options[:last_by_project]
scope = scope.group("projects.id").maximum(provider_options[:timestamp])
end
scope.to_a
end
end
lib/redmine/activity/fetcher.rb
def events(from = nil, to = nil, options={})
e = []
@options[:limit] = options[:limit]
@options[:last_by_project] = options[:last_by_project] if options[:last_by_project]
@scope.each do |event_type|
constantized_providers(event_type).each do |provider|
......
end
end
e.sort! {|a,b| b.event_datetime <=> a.event_datetime}
if options[:last_by_project]
e.sort
else
e.sort! {|a,b| b.event_datetime <=> a.event_datetime}
if options[:limit]
e = e.slice(0, options[:limit])
if options[:limit]
e = e.slice(0, options[:limit])
end
end
e
end
(4-4/9)