解决项目动态很慢,数据量很大的问题
This commit is contained in:
parent
ff23ecb9a8
commit
6c76cacb61
|
@ -49,11 +49,8 @@ module Redmine
|
|||
end
|
||||
|
||||
module ClassMethods
|
||||
# Time 2015-01-27 13:37:41
|
||||
# Author lizanle
|
||||
# Description 应该保持原来的写法更加容易懂
|
||||
# Returns events of type event_type visible by user that occured between from and to
|
||||
def find_events(event_type, user, from, to, options)
|
||||
def find_events(event_type, user, days, created_time, options)
|
||||
provider_options = activity_provider_options[event_type]
|
||||
raise "#{self.name} can not provide #{event_type} events." if provider_options.nil?
|
||||
|
||||
|
@ -94,23 +91,19 @@ module Redmine
|
|||
ActiveSupport::Deprecation.warn "acts_as_activity_provider with implicit :permission option is deprecated. Add a visible scope to the #{self.name} model or use explicit :permission option."
|
||||
scope = scope.scoped(:conditions => Project.allowed_to_condition(user, "view_#{self.name.underscore.pluralize}".to_sym, options))
|
||||
end
|
||||
# Time 2015-01-27 13:34:40
|
||||
# Time 2015-01-27 15:18:33
|
||||
# Author lizanle
|
||||
# Description 这段代码就用scope.all进行了查询,拖慢了速度,并且增加了时间跨度,时间跨度应该由管理员来调整,所以应该去掉
|
||||
=begin
|
||||
unless scope.all(provider_options[:find_options].dup).first.nil?
|
||||
# Description 删除 unless scope.all,因为这个执行查询,并且没有加入时间限制,与下边 scope.all(provider_options[:find_options].dup)的重复查询
|
||||
if options[:course]
|
||||
if provider_options[:timestamp].include? "updated_on"
|
||||
to = scope.scoped(:order => "#{provider_options[:timestamp]} desc").all(provider_options[:find_options].dup).first.updated_on
|
||||
else
|
||||
to = scope.scoped(:order => "#{provider_options[:timestamp]} desc").all(provider_options[:find_options].dup).first.created_on
|
||||
end
|
||||
if options[:course]
|
||||
from = (to - days.days) > created_time ? (to - days.days) : created_time.to_date
|
||||
else
|
||||
from = to - days.day - 1.years
|
||||
end
|
||||
else
|
||||
from = to - Setting.activity_days_default.to_i
|
||||
end
|
||||
=end
|
||||
|
||||
if from && to
|
||||
scope = scope.scoped(:conditions => ["#{provider_options[:timestamp]} BETWEEN ? AND ?", from, to])
|
||||
|
|
Loading…
Reference in New Issue