Subcommand search and search any to search inside tags' contents and not names.#823
Conversation
…ntents instead of names - `!tag search` will search for multiple keywords, separated by comma, and return tags that has ALL of these keywords. ` !tag search any` is the same as `!tag search` but it return tags that has ANY of the keyword instead.
- Refactored `if` block - change to only send result when there is any result. - Added better type hinting for `check` argument of `_get_tags_via_content` - changed from `callable` to `Callable[[Iterable], bool]`. Thanks to @MarkKoz 's reviews Co-Authored-By: Mark <markkoz@users.noreply.github.com>
…hen multiple tags are found. - Added a truthy check for each `query` since `','.split()` returns a list of two empty strings. - Changed from `Did you mean ...` to `Here are the tags containing the given keyword(s):` to be much more descriptive about the results - they are `tag` and not `term` to be searched.
lemonsaurus
left a comment
There was a problem hiding this comment.
Mostly high quality code, but I have a few objections before I can approve.
- Show the process of sanitizing the List[str] `keywords_processed`. - Show the process of finding tag for `matching_tags` ( was `founds` ). - Refactored the logic to find boolean `is_plural`. - Minor wording changes for docstring.
lemonsaurus
left a comment
There was a problem hiding this comment.
With these changes, I've got no objections. Looks good, nice work!
MarkKoz
left a comment
There was a problem hiding this comment.
It should be indicated somewhere in the embed that results are being truncated.
Co-Authored-By: Mark <kozlovmark@gmail.com>
|
You are right, the truncating was copied over from I've added paginator for it just like in |
- Split `_get_tags_via_content` - introduce `_send_matching_tags` - `_send_matching_tags` will send and paginate like `!tag` - Simplified `is_plural` even more.
MarkKoz
left a comment
There was a problem hiding this comment.
Using a paginator slipped my mind! Yes, that is a better solution than adding a truncation message somewhere. Creating a separate function to send the results was a good idea. I like that you changed the footer to explain how to show a tag - I think that's more useful than showing the keywords used.
Closes #804
This PR introduces two new subcommands to
!tagthat will allow searching for tags via contents instead of names:!tag searchwill search for multiple keywords, separated by comma, and return tags that has ALL of these keywords.!tag search anyis the same as!tag searchbut it return tags that has ANY of the keyword instead.Examples: