Skip to content
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

Allow batch disconnect for the batch strategy #15699

Conversation

Ladas
Copy link
Contributor

@Ladas Ladas commented Aug 1, 2017

Allow batch disconnect for the batch strategy

Example of ContainerImage batch disconnect strategy is here: #15698

Allow batch disconnect for the batch strategy
@Ladas
Copy link
Contributor Author

Ladas commented Aug 1, 2017

@miq-bot assign @agrare
@miq-bot add_label enhancement, performance
cc @cben

@miq-bot
Copy link
Member

miq-bot commented Aug 1, 2017

Checked commit Ladas@2cb8567 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
1 file checked, 0 offenses detected
Everything looks fine. 🏆


# Is the delete_method rails standard deleting method?
rails_delete = %i(destroy delete).include?(inventory_collection.delete_method)
if !rails_delete && inventory_collection.model_class.respond_to?(inventory_collection.delete_method)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These look like they could be cleaned up a bit, maybe move the logic into the InventoryCollection but that can be a follow-up PR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps InventoryCollection having :batch_delete_method param, instead of magic implication of having class method with same name?

Copy link
Member

@agrare agrare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@agrare agrare merged commit e45f2bb into ManageIQ:master Aug 2, 2017
@agrare agrare added this to the Sprint 66 Ending Aug 7, 2017 milestone Aug 2, 2017
inventory_collection.model_class.public_send(inventory_collection.delete_method, records.map(&:id))
else
# We have either standard :destroy and :delete rails method, or custom instance level delete method
# Note: The standard :destroy and :delete rails method can't be batched because of the hooks and cascade destroy
Copy link
Contributor

@cben cben Aug 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My impression is that delete doesn't do any cascading/callback and can be batched without instantiation using model.delete([ids...]) or where(...).delete_all.

The row is simply removed with an SQL DELETE statement on the record's primary key, and no callbacks are executed.
...
To enforce the object's before_destroy and after_destroy callbacks or any :dependent association options, use #destroy.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm right, I will remove the delete from there entirely, since we do not really use it anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants