ManageIQ / ManageIQ/inventory_refresh
`lazy_find` should accept lambda to preprocess value
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 1
- Forks
- 21
- PR merge metrics
- No merged PRs in 30d
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the implementation and tests for lazy_find, then compare its current behavior with the find examples in this issue. Done means the method accepts the shown block form and applies it to the found flavor value without introducing the ordering problem described.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100