ManageIQ / inventory_refresh

Apache License 2.0
1 stars 23 forks source link

`lazy_find` should accept lambda to preprocess value #85

Open miha-plesko opened 5 years ago

miha-plesko commented 5 years ago

We're hitting an issue where we have to copy value from Flavor to Vm, but divide it by 2^20 prior saving. Something like:

persister.flavors.build(
  ... 
  :memory => flavor.memory_in_mb.megabytes # store in bytes
)

persister.hardwares.build(
  ...
  :memory_mb => persister.flavors.find(flavor_ref).memory / 1.megabytes  # convert to megabytes
)

Problem is that we currently have to use .find() which may potentially result in ordering issues. Would it be possible to let .lazy_find() accept a block where we could preprocess the value? Something like this would be fantastic:

persister.flavors.lazy_find(flavor_ref) { |flavor| flavor.memory / 1.megabyte }

/cc @agrare

miq-bot commented 4 years ago

This issue has been automatically marked as stale because it has not been updated for at least 3 months.

If you can still reproduce this issue on the current release or on master, please reply with all of the information you have about it in order to keep the issue open.

Thank you for all your contributions! More information about the ManageIQ triage process can be found in the traige process documentation.

miq-bot commented 1 year ago

This issue has been automatically marked as stale because it has not been updated for at least 3 months.

If you can still reproduce this issue on the current release or on master, please reply with all of the information you have about it in order to keep the issue open.

Thank you for all your contributions! More information about the ManageIQ triage process can be found in the triage process documentation.