diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 944e60ca3..71510a6f3 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -36,6 +36,8 @@ class AdminController < ApplicationController scope = scope.like(params[:name]) if params[:name].present? @projects = scope.to_a + @last_activity = Redmine::Activity::Fetcher.new(User.current).events(nil, nil, :last_by_project => true).to_h + render :action => "projects", :layout => false if request.xhr? end diff --git a/app/views/admin/projects.html.erb b/app/views/admin/projects.html.erb index 0437f9e28..863265caf 100644 --- a/app/views/admin/projects.html.erb +++ b/app/views/admin/projects.html.erb @@ -22,6 +22,7 @@ <%=l(:label_project)%> <%=l(:field_is_public)%> <%=l(:field_created_on)%> + <%=l(:field_last_activity)%> @@ -30,6 +31,7 @@ <%= link_to_project_settings(project, {}, :title => project.short_description) %> <%= checked_image project.is_public? %> <%= format_date(project.created_on) %> + <%= format_date(@last_activity[project.id]) %> <%= 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?) %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 399c2e85a..3172839b2 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -254,6 +254,7 @@ en: 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 diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index 2e2e159cc..99bb3b780 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -222,6 +222,7 @@ pt-BR: 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 diff --git a/lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb b/lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb index 8f65eb720..18a1c8772 100644 --- a/lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb +++ b/lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb @@ -55,9 +55,8 @@ module Redmine scope = (provider_options[:scope] || self) - if from && to - scope = scope.where("#{provider_options[:timestamp]} BETWEEN ? AND ?", from, to) - end + scope = scope.where("#{provider_options[:timestamp]} >= ?", from) if from + scope = scope.where("#{provider_options[:timestamp]} <= ?", to) if to if options[:author] return [] if provider_options[:author_key].nil? @@ -78,6 +77,14 @@ module Redmine scope = scope.where(Project.allowed_to_condition(user, "view_#{self.name.underscore.pluralize}".to_sym, options)) end + if options[:next_by_project] + scope = scope.group("projects.id").minimum(provider_options[:timestamp]) + end + + if options[:last_by_project] + scope = scope.group("projects.id").maximum(provider_options[:timestamp]) + end + scope.to_a end end diff --git a/lib/redmine/activity/fetcher.rb b/lib/redmine/activity/fetcher.rb index 627a08441..23c649e76 100644 --- a/lib/redmine/activity/fetcher.rb +++ b/lib/redmine/activity/fetcher.rb @@ -85,6 +85,8 @@ module Redmine 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] + @options[:next_by_project] = options[:next_by_project] if options[:next_by_project] @scope.each do |event_type| constantized_providers(event_type).each do |provider| @@ -92,10 +94,16 @@ module Redmine end end - e.sort! {|a,b| b.event_datetime <=> a.event_datetime} + if options[:last_by_project] + e.sort! + elsif options[:next_by_project] + e.sort! {|a,b| b <=> a} + 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