Provide filter_results to refine a search - #282
Open
ekohl wants to merge 1 commit into
Open
Conversation
bastelfreak
approved these changes
Jul 21, 2023
ekohl
force-pushed
the
filter-results
branch
from
February 27, 2024 12:55
7ac23d0 to
5e95739
Compare
bastelfreak
reviewed
Jun 8, 2024
| # @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 |
Member
There was a problem hiding this comment.
I think we should rebase this for the facterdb 3 release when we switch to strings by default
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.
ekohl
force-pushed
the
filter-results
branch
from
September 13, 2024 14:00
9bdb37a to
6f98c73
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.