REVIEW - convert old find api to new AREL api.

the bad part: replaced includes with joins wich results in a INNER JOINS instead of a LEFT OUTER JOIN in the final sql query. this might lead to lost data on null-associations. happily, in the openproject core there are only associations using acts_as_activity. if a plugins uses acts_as_activity you should be aware of the JOIN-problem.
pull/1186/head
Philipp Tessenow 12 years ago
parent 16116123b4
commit f06d7486d2
  1. 6
      lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb

@ -53,7 +53,7 @@ module Redmine
module ClassMethods
# Returns events of type event_type visible by user that occured between from and to
def find_events(event_type, user, from, to, options)
provider_options = activity_provider_options[event_type]
provider_options = activity_provider_options[event_type].dup
raise "#{self.name} can not provide #{event_type} events." if provider_options.nil?
scope_options = {}
@ -74,7 +74,9 @@ module Redmine
end
journal_class.with_scope(:find => scope_options) do
journal_class.find(:all, provider_options[:find_options].dup)
query = journal_class.where(provider_options[:find_options][:conditions])
query = query.joins(provider_options[:find_options][:include]) if provider_options[:find_options][:include]
query
end
end
end

Loading…
Cancel
Save