-
Notifications
You must be signed in to change notification settings - Fork 897
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
Store created updated and deleted records #15603
Store created updated and deleted records #15603
Conversation
Allow IC to store what was created/updated/deleted
Unify default and concurrent_safe savers and store counts of what was created/updated/deleted.
Store counts for concurrent safe batch saver. Counts and ids of what was created/updated/deleted.
Test that we correctly store what was created/updated/deleted in IC
# Returns a hash with a simple record identity | ||
def record_identity(record) | ||
{ | ||
:id => record.try(:[], :id) || record.try(:id) |
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.
in what scenario could both try
fail? if it's possible, we may get one or more {:id => nil} in the arrays, not very useful. actually record.id
may also be nil if for some reason it's unsaved.
Can we make it raise exceptions, and elsewhere assume all records in these arrays will have id?
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.
hm, it should not fail. The storing is only on places with actual created/updated/deleted records.
But I can add the exception.
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.
done
Move store_created_records code after records creation
Enforce that identity of the create/updated/deleted record is present
Correct storing of deleted and updated records for a batch strategy
|
||
# Returns a hash with a simple record identity | ||
def record_identity(record) | ||
identity = record.try(:[], :id) || record.try(:[], "id") || record.try(:id) |
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.
This looks overly complicated, it seems like the caller has a better idea of how to get the id
out of what its storing than this. Would it make more sense to pass in the id
for the created/updated/deleted records?
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.
hm, I would rather have it here, since I can later easily add more params, like manager_ref
Checked commits Ladas/manageiq@bfcdaca~...42f74aa with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 app/models/manager_refresh/save_collection/saver/base.rb
|
@@ -3,55 +3,6 @@ module Saver | |||
class ConcurrentSafe < ManagerRefresh::SaveCollection::Saver::Base | |||
private | |||
|
|||
def save!(inventory_collection, association) |
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.
+1 for consolidating the save! methods now
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.
LGTM 👍
Store created updated and deleted records. This information can be than used in post refresh to e.g. queue up more jobs for created items. Or by another graph node for post processing to e.g. assign/delete records from folders.