diff options
author | Marius Balteanu <marius.balteanu@zitec.com> | 2024-05-03 13:14:18 +0000 |
---|---|---|
committer | Marius Balteanu <marius.balteanu@zitec.com> | 2024-05-03 13:14:18 +0000 |
commit | 8b57ffc3c750b253e316fbfd8871d5c2da045557 (patch) | |
tree | e4a8c9aa0471fa6e95adf45e3e11bd1e69b5e1a5 /lib | |
parent | 6524dd3eaa9f36906060d6cf747086ee5c8ebcec (diff) | |
download | redmine-8b57ffc3c750b253e316fbfd8871d5c2da045557.tar.gz redmine-8b57ffc3c750b253e316fbfd8871d5c2da045557.zip |
Adds the date of the last activity to the list of available columns for Projects (#23954).
Patch by Frederico Camara (@fredsdc) and Marius BÄ‚LTEANU (@marius.balteanu).
git-svn-id: https://svn.redmine.org/redmine/trunk@22811 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib')
-rw-r--r-- | lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb | 9 | ||||
-rw-r--r-- | lib/redmine/activity/fetcher.rb | 11 |
2 files changed, 14 insertions, 6 deletions
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 5954d501d..ac334c19a 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 @@ -64,9 +64,8 @@ module Redmine ActiveSupport::Deprecation.warn "acts_as_activity_provider with implicit :scope option is deprecated. Please pass a scope on the #{self.name} as a proc." end - 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? @@ -87,6 +86,10 @@ module Redmine 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("#{Project.table_name}.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 cbd20425d..4264c2e5d 100644 --- a/lib/redmine/activity/fetcher.rb +++ b/lib/redmine/activity/fetcher.rb @@ -87,6 +87,7 @@ 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] @scope.each do |event_type| constantized_providers(event_type).each do |provider| @@ -94,10 +95,14 @@ module Redmine 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 |