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

Adapted the website search for better matching #6477

Merged
merged 1 commit into from
Dec 19, 2020

Conversation

xFrednet
Copy link
Member

  • This adds the ability to search for ids with dashes and spaces in the name.
    • Example: missing-errors-doc and missing errors doc are now valid aliases for lint names
  • It also improves the fuzzy search in the description. This search will now match any lint that where all searched words are inside the description.
    • Example: doc section finds two lints in our selection

This was suggested/discussed on Zulip

Testing

These changes can be tested locally by:

  1. Clone this branch
  2. Download the current lint index from the gh-pages branch
  3. Put it next to the util/gh-pages/index.html and open the html file. Make sure that it can load the lint data. (Browsers can be a bit iffy when opening a loacl html page and loading data)

Note

I found that searching only a few characters (< 3) seams slow and deleting one even more as almost every lint description contains them. This also happens in our current lint list. We could change the search to only be triggered if the search field contains more than 3 letters to slightly improve performance.


changelog: Adapted the website search for better matching

@rust-highfive
Copy link

r? @llogiq

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Dec 19, 2020
@@ -89,7 +89,7 @@ <h1>ALL the Clippy Lints</h1>
</div>

<article class="panel panel-default" id="{{lint.id}}"
ng-repeat="lint in data | filter:byLevels | filter:byGroups | filter:search | orderBy:'id' track by lint.id" on-finish-render="ngRepeatFinished">
Copy link
Member Author

@xFrednet xFrednet Dec 19, 2020

Choose a reason for hiding this comment

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

I removed the on-finish-render="ngRepeatFinished" as it was restarting the query even though nothing has changed. Changing one of the settings causes the query to be reevaluated automatically.

Copy link
Contributor

@llogiq llogiq left a comment

Choose a reason for hiding this comment

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

This is something that I recently would have found useful. Thank you!

@bors r+

@ebroto
Copy link
Member

ebroto commented Dec 19, 2020

@bors r+

(@llogiq, bors is a bit hard headed and won't listen to you in review comments 🙂)


We could change the search to only be triggered if the search field contains more than 3 letters to slightly improve performance.

I think that's a good idea, maybe we could do that in a follow-up PR? Thanks a lot for working on this!

@bors
Copy link
Contributor

bors commented Dec 19, 2020

📌 Commit 2814ee4 has been approved by ebroto

@bors
Copy link
Contributor

bors commented Dec 19, 2020

⌛ Testing commit 2814ee4 with merge 12a35ab...

@ebroto
Copy link
Member

ebroto commented Dec 19, 2020

(oops should have r=llogiq'd)

@bors
Copy link
Contributor

bors commented Dec 19, 2020

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: ebroto
Pushing 12a35ab to master...

@bors bors merged commit 12a35ab into rust-lang:master Dec 19, 2020
@xFrednet
Copy link
Member Author

Sure, I'm working on another website issue and limiting the search is an easy change.

No problem @ebroto. I'm currently really enjoy being a part of this, also thanks to all the work you and the team are doing!

bors added a commit that referenced this pull request Dec 23, 2020
Website issue tracker link and better search performance

This PR implements some improvements to the website:
1. Added a "Search on Github" link to the "Known problems" section (Closes #5386)
    ![example_3](https://user-images.githubusercontent.com/17087237/102718215-e9f12500-42de-11eb-8c1b-487f8184aaf7.png)
    <details>
    <summary>Another mock up I created with the GitHub logo</summary>

    ![example_2](https://user-images.githubusercontent.com/17087237/102718281-3472a180-42df-11eb-99b8-7f6d76da2b55.png)

    </details>

2. Only starting the search after three letters and improving the search performance in general. (Followup #6477)

### Testing
These changes can be tested locally by:
1. Clone this branch
2. Download the current lint index from the [gh-pages branch](https://github.com/rust-lang/rust-clippy/blob/gh-pages/master/lints.json)
3. Put it next to the `util/gh-pages/index.html` and open the html file. Make sure that it can load the lint data. (Browsers can be a bit iffy when opening a local html page and loading data)

### Sources for search performance:
1. [A stackoverflow about angular filter performance](https://stackoverflow.com/questions/26876514/optimize-angular-filter-performance)
    * I selected a search debounce of 50ms that's fast enough to catch fast deletion and typing but responsive enough to not bother the user
2. [A stackoverflow about string comparison speeds](https://stackoverflow.com/questions/5296268/fastest-way-to-check-a-string-contain-another-substring-in-javascript)
3. [JS benchmarks for string search performance (`indexOf` seams to be the best)](https://jsben.ch/9cwLJ)

Note: The performance is still a bit poor when going from a specific lint to no search filter. I suspect that angular is recreating all lint items when the filter is cleared causing a major lag spike. The filter functions is at least optimized for little to no search.

---

changelog: Added a "Search on GitHub" link to the website
@xFrednet xFrednet deleted the 0000-enable-search-with-dashes branch July 28, 2021 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants