Skip to content
This repository was archived by the owner on Feb 29, 2020. It is now read-only.

Conversation

Mardak
Copy link
Member

@Mardak Mardak commented Sep 20, 2016

Fix #1302 by passing the filter to PlacesProvider allowing it to do the multi-token matching on title/url. These SQL-filtered results are tagged with the filter they were matched with, so that the selector only shows the results that are relevant to the current filter. This is faster because the 20 results the timeline gets are already most likely going to match the filter instead of going through many "pages" of non-matches.

This also fixes #1261 at the same time as it doesn't try showing many pages of results when clearing search. By including the tagged filter, more specific searches can be quickly ignored when deleting in addition to there being fewer fetched rows in the first place.

r?@sarracini

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 8f00705 on Mardak:gh1302-loading into * on mozilla:master*.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.01%) to 92.533% when pulling f77db2f on Mardak:gh1302-loading into 0a91220 on mozilla:master.

// Match each token in either the title or url
let tokens = filter.trim().toLowerCase().split(/\s+/);
tokens.forEach((token, i) => {
filterClause = `${filterClause} AND (
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: how come we're using the blank string from filterClause here?

Copy link
Member Author

Choose a reason for hiding this comment

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

The other Clauses start with "AND ..." because they're chaining to the WHERE. This is the same except there's a dynamic number of chains based on how many tokens are being used, e.g., " AND token1 ... AND token2 ... AND token3 ..." The empty string is the initial value so that the subsequent token clauses can be concatenated.

function RequestMoreRecentLinks(beforeDate, filter = "") {
return RequestRecentLinks({
data: {beforeDate},
data: {beforeDate, filter},
Copy link
Contributor

Choose a reason for hiding this comment

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

just to make sure, this is for infinite scrolling yes?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup. It's to include the query for fetching more when infinitely scrolling.

Filter,
History
History: Object.assign({}, History, {
// Only include rows that are less filtered than the current filter
Copy link
Contributor

Choose a reason for hiding this comment

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

the comment is kind of unclear - could you explain?

Copy link
Member Author

Choose a reason for hiding this comment

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

A query of "query" is more filtered/specific than a query of "qu" which is more specific than "". If the current query is "que" it would include rows for "" and "qu" but not "query" because "query" is more specific. This is desired because the user might be searching for "queso".

@sarracini
Copy link
Contributor

looks good, R+!

@Mardak Mardak merged commit 85a2d5f into mozilla:master Sep 29, 2016
@Mardak Mardak deleted the gh1302-loading branch September 29, 2016 16:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Search endlessly loading... Improve responsiveness when clearing timeline search
3 participants