Skip to content

Provide filter_results to refine a search - #282

Open
ekohl wants to merge 1 commit into
voxpupuli:masterfrom
ekohl:filter-results
Open

Provide filter_results to refine a search#282
ekohl wants to merge 1 commit into
voxpupuli:masterfrom
ekohl:filter-results

Conversation

@ekohl

@ekohl ekohl commented Jul 21, 2023

Copy link
Copy Markdown
Member

rspec-puppet-facts has a pattern where it does a lot of small searches for every OS. By doing a single complex FacterDB.get_facts call to get the only supported operating systems and then further refining that result it can use the cache provided by FacterDB.get_facts.

This is quite hacky now because it duplicates internals from JGrep to avoid serializing to JSON and parsing that again. The conversions to symbols and back to strings is also inefficient.

voxpupuli/rspec-puppet-facts#158 was the inspiration for this.

Comment thread lib/facterdb.rb Outdated
# @param filter [Object] The filter to convert to jgrep string
# @return [Array[Hash[Symbol, Any]]] Array of hashes of facts
def self.filter_results(results, filter)
# TODO: it's really inefficient to do to_s and to_sym all the time

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we should rebase this for the facterdb 3 release when we switch to strings by default

@ekohl

ekohl commented Jun 17, 2024

Copy link
Copy Markdown
Member Author

Rebased, but not further tested.

rspec-puppet-facts has a pattern where it does a lot of small searches
for every OS. By doing a single complex FacterDB.get_facts call to get
the only supported operating systems and then further refining that
result it can use the cache provided by FacterDB.get_facts.

This is quite hacky now because it duplicates internals from JGrep to
avoid serializing to JSON and parsing that again.
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.

3 participants