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

Fakerbot not searching namespace #1566

Closed
richardbulger opened this issue Mar 7, 2019 · 9 comments
Closed

Fakerbot not searching namespace #1566

richardbulger opened this issue Mar 7, 2019 · 9 comments

Comments

@richardbulger
Copy link
Contributor

Example1:

C:\Users\richard.bulger>faker search beer -v

Sorry, we couldn't find a match 😢


C:\Users\richard.bulger>faker search yeast -v
Faker
└── yeast=> 5526 - Brettanomyces lambicus
Faker
├── as_you_like_it=> I like this place and willingly could waste my time in it.
└── as_you_like_it_quote=> Can one desire too much of a good thing?.

Note that the first result for beer returns nothing. But the second for yeast, which is a method of beer does. (Also note that the namespace name isn't shown in the result tree, which I've raised in #1565 )

Also, in the second result, you can see it also returns irrelevant results from the Shakespeare namespace. Not sure why.

Example2:

C:\Users\richard.bulger>faker search simpsons -v
Faker
└── i_groups=> Two Two

Doesn't return any simpons namespace stuff, but returns a Kpop one...

@vbrazo
Copy link
Member

vbrazo commented Mar 8, 2019

@akabiru ☝️

@richardbulger
Copy link
Contributor Author

richardbulger commented Mar 8, 2019

Example 2 is matching "simpsons" as the kpop method is split in 2 before comparison, "i" and "group". As such, it will match anything with an "i" in the search string:

C:\Users\richard.bulger>faker search xxxxxxxxxxxxxxxxxxxx -v

Sorry, we couldn't find a match 😢


C:\Users\richard.bulger>faker search xxxxxxxxxxxxxxxxxxxxi -v
Faker
└── i_groups=> Seo Taiji and Boys

Same with example 1, where "as" is in the search term "yeast"

Edit: maybe I should split this out as a separate issue?

@akabiru
Copy link
Contributor

akabiru commented Mar 9, 2019

Thanks for reporting this @richardbulger . This is actually an Open Issue on Fakerbot https://github.com/akabiru/fakerbot/issues/8 .

At the moment, search only matches against the method name parts -> https://github.com/stympy/faker/blob/master/lib/cli/reflectors/search.rb#L39-L42 I'm very open to suggestions on how we could improve the search algo. 🙂

@akabiru
Copy link
Contributor

akabiru commented Mar 12, 2019

Hey folks, @Jdcorley has been looking into this on https://github.com/akabiru/fakerbot/issues/8 - we're shifting the conversation here. 🙂

The list reflector actually builds a hash of faker constants and their methods via the Reflectors::List#all_descendants_with_methods method.

We could potentially search against that data store? i.e. match against the constant (key) and also the methods

Screenshot 2019-03-12 at 21 13 03

Curious to know what you think.

@richardbulger
Copy link
Contributor Author

Sounds good to me. I think it's valuable that it searches full namespace hierarchy (eg TvShows and BojackHorseman) along with the methods.
I think it would be good if it lists the methods of the namespace in the results, also

@akabiru
Copy link
Contributor

akabiru commented Mar 19, 2019

@Jdcorley any update on this one? Please shout if you have any Qs. 🙂

@Jdcorley
Copy link

@akabiru I’m very close to solving it haha I have the search including the namespaces now but now it’s just dumping all the namespaces during the search plus any methods that match the query. So I’m working on getting it to select the right namespaces to return relevant to the query.

@akabiru
Copy link
Contributor

akabiru commented Mar 19, 2019

Awesome! Feel free to raise a Draft PR maybe we can help unblock that bit. 👍

@bpleslie
Copy link
Member

We should be able to close this issue. Resolved in akabiru/faker-bot#38

@vbrazo vbrazo closed this as completed Aug 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants