Skip to content

Subcommand search and search any to search inside tags' contents and not names.#823

Merged
MarkKoz merged 6 commits into
masterfrom
tag-search-searches-tags-via-content-instead-of-names
Mar 9, 2020
Merged

Subcommand search and search any to search inside tags' contents and not names.#823
MarkKoz merged 6 commits into
masterfrom
tag-search-searches-tags-via-content-instead-of-names

Conversation

@ikuyarihS
Copy link
Copy Markdown
Contributor

Closes #804

This PR introduces two new subcommands to !tag that will allow searching for tags via contents 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.

Examples:

image

…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.
@ikuyarihS ikuyarihS added t: feature New feature or request good first issue Good for newcomers p: 3 - low Low Priority a: information Related to information commands: (doc, help, information, reddit, site, tags) status: needs review labels Mar 8, 2020
@ikuyarihS ikuyarihS requested a review from a team as a code owner March 8, 2020 04:45
@ikuyarihS ikuyarihS requested review from MrHemlock and jerbob and removed request for a team March 8, 2020 04:45
Comment thread bot/cogs/tags.py Outdated
Comment thread bot/cogs/tags.py Outdated
Comment thread bot/cogs/tags.py Outdated
- 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>
Comment thread bot/cogs/tags.py Outdated
…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.
Copy link
Copy Markdown
Contributor

@lemonsaurus lemonsaurus left a comment

Choose a reason for hiding this comment

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

Mostly high quality code, but I have a few objections before I can approve.

Comment thread bot/cogs/tags.py Outdated
Comment thread bot/cogs/tags.py Outdated
Comment thread bot/cogs/tags.py Outdated
- 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.
Copy link
Copy Markdown
Contributor

@lemonsaurus lemonsaurus left a comment

Choose a reason for hiding this comment

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

With these changes, I've got no objections. Looks good, nice work!

Copy link
Copy Markdown
Contributor

@MarkKoz MarkKoz left a comment

Choose a reason for hiding this comment

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

It should be indicated somewhere in the embed that results are being truncated.

Comment thread bot/cogs/tags.py Outdated
Co-Authored-By: Mark <kozlovmark@gmail.com>
@ikuyarihS
Copy link
Copy Markdown
Contributor Author

You are right, the truncating was copied over from !tags where if multiple results are found, they are already sorted by matching scores, which is not the case for this.

I've added paginator for it just like in !tags

- Split `_get_tags_via_content` - introduce `_send_matching_tags`
- `_send_matching_tags` will send and paginate like `!tag`
- Simplified `is_plural` even more.
Copy link
Copy Markdown
Contributor

@MarkKoz MarkKoz left a comment

Choose a reason for hiding this comment

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

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.

@MarkKoz MarkKoz merged commit 2c305c1 into master Mar 9, 2020
@MarkKoz MarkKoz deleted the tag-search-searches-tags-via-content-instead-of-names branch March 9, 2020 05:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: information Related to information commands: (doc, help, information, reddit, site, tags) good first issue Good for newcomers p: 3 - low Low Priority t: feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tag-search command to search tags via their contents instead of names.

3 participants