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

New search functionality #265

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

alonr619
Copy link
Contributor

…ltering.

Link to Relevant Issue

This pull request resolves #138

Description of Changes

Adds new search functionality to event transcript search, including strict search (use double quotes), negative search (put a ! before the double quotes), start filtering (put a ^ before the double quotes) and end filtering (put a $ before the double quotes).

For example, ^"1" $"2" "3" !"4" would only show strings that start with 1, end with 2, include 3, and don't include 4.

Linked to Forked Storybook Site

Here

Copy link
Contributor

@jonlin14 jonlin14 left a comment

Choose a reason for hiding this comment

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

On first pass

  • linter is saying varietyRoles on line 15 isn't used, is it necessary? If not lets remove it.
  • Lets also get rid of the console logs.
  • I tried testing "Thank" !"you", looking for sentences that has only "Thank" but not "you" and it errored out, unable to read undefined from text. It looks like it's on line 188, I think if there are results from a double quote search but then they all subsequently get filtered out from using !"", it's trying to read from an answer with no results thus erroring out.
  • Filtering seems to only be working for full strings right now, is that intended? Also looks like the highlighting is off. It can be adjusted in the TranscriptItem.tsx file. You can look at line 177 to see the Highlighter component.

filter1

filter2

@evamaxfield
Should we include text that tells the user that they can use quotes and filters?
Should this be case sensitive?

Copy link
Collaborator

@BrianL3 BrianL3 left a comment

Choose a reason for hiding this comment

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

This may be an issue with my browser/extensions combination, but the feature does not work for me. I am running Chrome, with PrivacyBadger and uBlock Origin. Javascript is enabled.

Also, this is a prime candidate for tests. The logic in it is complex enough that I can't tell if it works at a glance, but you could

  1. split this chunk of code into smaller, testable chunks
  2. set up some mocks with test queries (with quotes, limiters, etc)
  3. test each small chunk to make sure it does what you think it does
  4. test the code as a whole to make sure it works

There are some testing files in the repo already, use them to see best practices.

newTerm.substring(0, indices[i * 2]) +
newTerm.substring(indices[i * 2 + 1] + 1, newTerm.length);
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

can you pull everything from line 104-145ish into a utility function that just lives a neighboring folder? e.g. util/, util/, etc? Cleaner and more testable to keep the logic outside of views, as each function can be assessed on its sole purpose.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do this once I fix John's bugs, thanks for the suggestion!

const tokenizedQuery = removeStopwords(cleanedQuery.split(" "));
console.log("3");
if (!cleanedQuery || tokenizedQuery.length === 0) {
// empty query or no valid tokens to search
Copy link
Collaborator

Choose a reason for hiding this comment

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

it seems this comment needs to be updated?

@evamaxfield
Copy link
Member

@evamaxfield
Should we include text that tells the user that they can use quotes and filters?
Should this be case sensitive?

Yes absolutely. Please include some sort of helper text. Can be on hover. Can also save that for a future PR though.

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

Successfully merging this pull request may close these issues.

Implement strict search and other useful search operators
4 participants