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

Set delay for typeahead search #4180

Closed
5 tasks
kevinzluo opened this issue Dec 8, 2018 · 2 comments
Closed
5 tasks

Set delay for typeahead search #4180

kevinzluo opened this issue Dec 8, 2018 · 2 comments
Labels
first-timers-only They need to be well-formatted using the First-timers_Issue_Template. fto-candidate issues which are meant to be solved by first timers but aren't well-formatted yet

Comments

@kevinzluo
Copy link
Collaborator

Hi, this is a first-timers-only issue built off #3472 . This means we've worked to make it more legible to folks who either haven't contributed to our codebase before, or even folks who haven't contributed to open source before.

If that's you, we're interested in helping you take the first step and can answer questions and help you out as you do. Note that we're especially interested in contributions from people from groups underrepresented in free and open source software!

We know that the process of creating a pull request is the biggest barrier for new contributors. This issue is for you 💝

If you have contributed before, consider leaving this one for someone new, and looking through our general help wanted issues. Thanks!

🤔 What you will need to know.

Nothing. This issue is meant to welcome you to Open Source :) We are happy to walk you through the process.

📋 Step by Step

  • 🙋 Claim this issue: Comment below. If someone else has claimed it, ask if they've opened a pull request already and if they're stuck -- maybe you can help them solve a problem or move it along!

  • 📝 Update the file restful_typeahead.js in the plots2 repository (press the little pen Icon) and edit the line as shown below.

See this page for some help in taking your first steps!
Here is where the change should be made:

var typeahead = $(el).typeahead({
items: 10,
minLength: 3,
showCategoryHeader: true,
autoSelect: false,
source: function (query, process) {
var encoded_query = encodeURIComponent(query);
var qryType = $(el).attr('qryType');
return $.getJSON('/api/srch/' + qryType + '?query=' + encoded_query, function (data) {
return process(data.items);
},'json');
},

Below is a "diff" showing in red (and a -) which lines to remove, and in green (and a +) which lines to add:

    var typeahead = $(el).typeahead({
      items: 10,
      minLength: 3,
+     delay: 350,
      showCategoryHeader: true,
      autoSelect: false,
      source: function (query, process) {
        var encoded_query = encodeURIComponent(query);
        var qryType = $(el).attr('qryType');
        return $.getJSON('/api/srch/' + qryType + '?query=' + encoded_query, function (data) {
          return process(data.items);
        },'json');
      },

If you already have plots2 setup locally, you can also help us further test this issue!
Currently the 350 ms delay is based on pure speculation here.
You may set the delay to a desired number, then check out how many search requests are being made using your browser.

  • Start plots2

  • Then open up the inspector (Ctrl + shift + i in most browsers, or just right click and press inspect element).

  • Open up the "Network" tab.

  • Start typing in the search bar. Watch the search queries appear in the network tab.
    image

  • We would like to have the least search queries as possible, but also not force the user to wait too long.

  • 💾 Commit your changes

  • 🔀 Start a Pull Request. There are two ways how you can start a pull request:

  1. If you are familiar with the terminal or would like to learn it, here is a great tutorial on how to send a pull request using the terminal.

  2. You can also edit files directly in your browser and open a pull request from there. Please make sure to insert the issue number into the PR.

  • 🏁 Done Ask in comments for a review :)

🤔❓ Questions?

Leave a comment below!

Is someone else already working on this?

We encourage you to link to this issue by mentioning the issue # in your pull request, so we can see if someone's already started on it. If someone seem stuck, offer them some help! Otherwise, take a look at some other issues you can help with. Thanks!

(This issue was created by First-Timers-Bot.)

@kevinzluo kevinzluo added first-timers-only They need to be well-formatted using the First-timers_Issue_Template. fto-candidate issues which are meant to be solved by first timers but aren't well-formatted yet labels Dec 8, 2018
@wanzulfikri
Copy link
Contributor

I would like to try to solve this. Can I?

@kevinzluo
Copy link
Collaborator Author

Sure! Go ahead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
first-timers-only They need to be well-formatted using the First-timers_Issue_Template. fto-candidate issues which are meant to be solved by first timers but aren't well-formatted yet
Projects
None yet
Development

No branches or pull requests

2 participants