diff options
author | Go MAEDA <maeda@farend.jp> | 2020-10-17 02:02:50 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2020-10-17 02:02:50 +0000 |
commit | e48ff4882010df59f467433979fe27ebec39c0ee (patch) | |
tree | 8adad19a6932cf9cc364b300e9ddf8488412f2b3 /lib/plugins | |
parent | d9c6249a9cdf97010a992fd2c52e68c64f6a4e99 (diff) | |
download | redmine-e48ff4882010df59f467433979fe27ebec39c0ee.tar.gz redmine-e48ff4882010df59f467433979fe27ebec39c0ee.zip |
Evaluate acts_as_activity_provider's scope lazily (#33664).
Patch by Pavel Rosický.
git-svn-id: http://svn.redmine.org/redmine/trunk@20148 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/plugins')
-rw-r--r-- | lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb | 9 |
1 files changed, 8 insertions, 1 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 21e1ee473..5e98a0fee 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,7 +55,14 @@ module Redmine provider_options = activity_provider_options[event_type] raise "#{self.name} can not provide #{event_type} events." if provider_options.nil? - scope = (provider_options[:scope] || self) + scope = provider_options[:scope] + if !scope + scope = self + elsif scope.respond_to?(:call) + scope = scope.call + else + 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) |