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
|
# File 'lib/flu-rails/util.rb', line 4
def export_existing_entities_to_events(event_publisher, event_factory, entity_types=nil)
entity_types ||= find_all_tracked_entity_types(entity_types)
check_that_all_entity_types_have_created_at(entity_types)
Flu.logger.level = Logger::WARN
total_number_of_entity_types = entity_types.size
current_entity_type_index = 0
entity_types.each do | entity_type |
entities = entity_type.all
total_number_of_entities = entities.size
current_entity_index = 0
current_entity_type_index += 1
association_columns = entity_type.flu_association_columns
user_metadata_lambda = entity_type.flu_user_metadata_lambdas[:create]
ignored_model_changes = entity_type.flu_ignored_model_changes
entities.each do |entity|
print "\r" unless current_entity_index == 0
current_entity_index += 1
print "#{entity_type} (#{current_entity_type_index}/#{total_number_of_entity_types}) : #{current_entity_index}/#{total_number_of_entities}"
data = (entity, event_factory, user_metadata_lambda, association_columns, ignored_model_changes)
event = event_factory.build_entity_change_event(data)
event.timestamp = entity.created_at unless entity.created_at.nil?
event_publisher.publish(event)
print "\n" if current_entity_index == total_number_of_entities
end
end
end
|