-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Add an option to store record changes #115
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -177,9 +177,12 @@ def init_ic_relations(dependency_attributes, parent_inventory_collections = nil) | |
# for the batch saver strategy. | ||
# @param targeted [Boolean] True if the collection is targeted, in that case it will be leveraging :manager_uuids | ||
# :parent_inventory_collections and :targeted_arel to save a subgraph of a data. | ||
# @param track_record_changes [Boolean/Array] By default false. If false no changes to the InventoryObject will be stored, | ||
# otherwise changes to properties enumerated in the array will be stored for use by other inventory collections | ||
# Example: :track_record_changes => [:name, :raw_power_state] | ||
Comment on lines
+180
to
+182
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NOTE: I went back and forth a lot on a separate attribute to track the filter plus a boolean to turn on/off, versus combining them all in one attribute. On one hand it is handy to only need one attribute (we have a lot of knobs here already) on the other hand could be confusing to have a boolean/array datatype. |
||
def init_flags(complete, create_only, check_changed, | ||
update_only, use_ar_object, targeted, | ||
assert_graph_integrity) | ||
assert_graph_integrity, track_record_changes) | ||
@complete = complete.nil? ? true : complete | ||
@create_only = create_only.nil? ? false : create_only | ||
@check_changed = check_changed.nil? ? true : check_changed | ||
|
@@ -188,6 +191,7 @@ def init_flags(complete, create_only, check_changed, | |
@use_ar_object = use_ar_object || false | ||
@targeted = !!targeted | ||
@assert_graph_integrity = assert_graph_integrity.nil? ? true : assert_graph_integrity | ||
@track_record_changes = process_track_record_changes(track_record_changes) | ||
end | ||
|
||
# @param attributes_blacklist [Array] Attributes we do not want to include into saving. We cannot blacklist an | ||
|
@@ -390,6 +394,7 @@ def init_changed_records_stats | |
@created_records = [] | ||
@updated_records = [] | ||
@deleted_records = [] | ||
@record_changes = {} | ||
end | ||
|
||
# Processes passed saver strategy | ||
|
@@ -450,6 +455,16 @@ def process_retention_strategy(retention_strategy) | |
":destroy and :archive" | ||
end | ||
end | ||
|
||
def process_track_record_changes(track_record_changes) | ||
return false unless track_record_changes | ||
|
||
if !track_record_changes.kind_of?(Array) | ||
raise "Invalid value for track_record_changes: #{track_record_changes}, allowed values are false or an Array" | ||
end | ||
|
||
track_record_changes.map(&:to_s) | ||
end | ||
end | ||
end | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.