3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/distyll.rb', line 3
def self.run(base_models, created_since)
@model_profiles = Hash.new
base_models.each do |model|
if @model_profiles[model].nil?
base_profile = DistyllModelProfile.new(model, true)
base_profile.load_ids_by_timestamp(created_since)
@model_profiles[model] = base_profile
end
end
prior_count = -1
while prior_count != current_count
prior_count = current_count
@model_profiles.each_value &:demote_current_ids
@model_profiles.dup.each_value do |profile|
unless profile.prior_ids.blank?
profile.associations.each do |a|
contagious_has_many = profile.include_has_many && !(a.belongs_to? || a.has_and_belongs_to_many?)
find_or_store_profile(a.klass, contagious_has_many).load_ids(profile.get_new_associated_ids(a))
end
end
end
end
@model_profiles.each_value do |profile|
profile.copy_records
end
end
|