-
Notifications
You must be signed in to change notification settings - Fork 23
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
basic search functionality from probe search service #602
Conversation
params.set('limit', resultsLimit); | ||
params.set('select', 'name,definition,type'); | ||
params.set('product', `eq.${product}`); | ||
params.set('type', 'neq.event'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type
may depend on product. Although I don't think this hurts fenix, or other glean products currently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep I expect adjustments here - should be easier now that it's not a long string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we'll probably understand more when we start pointing this at Fenix probes in GLAM, but let's expect these to be moved to firefox-desktop.js
at some point
if (aHas && !bHas) return -1; | ||
if (bHas && !aHas) return 1; | ||
return 0; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the near future I plan to update the probe-search to rank the results based on weighting of the matches. Once that lands this could likely go away. Just a heads up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea I'd prefer if this were gone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is muuuuch nicer already! I have a few more changes / comments to request. Overall very much on the right track. I'm mostly focused on meeting (mostly) the same design as before, but there might be a few tweaks to make sure we're at implicit parity here.
src/state/api.js
Outdated
@@ -54,3 +54,32 @@ export async function getProbeData(params, token) { | |||
}); | |||
return data; | |||
} | |||
|
|||
export async function getSearchResults(queryString, resultsLimit) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you're returning a Promise
here (and the await
keyword below is not necessary) we can just make this a regular function
export async function getSearchResults(queryString, resultsLimit) { | |
export function getSearchResults(queryString, resultsLimit) { |
src/state/api.js
Outdated
return URLResult; | ||
}; | ||
|
||
return await fetch(getFormattedSearchURL(queryString)).then(async (r) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the await
keyword is necessary here, since I would presume that whatever utilizes the return value of this function will be awaiting anyway
return await fetch(getFormattedSearchURL(queryString)).then(async (r) => { | |
return fetch(getFormattedSearchURL(queryString)).then(async (r) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
<div>your search produced 0 results</div> | ||
</div> | ||
{:else if results.status} | ||
<!-- TODO: This should be pretty. --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<!-- TODO: This should be pretty. --> | |
<!-- FIXME: This should be pretty. --> |
transition:fly={{ duration: 20, y: -10 }} | ||
class="telemetry-results"> | ||
<div class="header-container"> | ||
{#if results.length} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I mentioned this in the previous PR, but it feels like there should be another case here, where if we are either waiting for the throttle timer to finish or we're waiting for a result set, where we say fetching probes
+ a spinner or something like that. Right now, I type and nothing immediately happens, and it feels like a step back in terms of experience.
{:else if results.status} | ||
<!-- TODO: This should be pretty. --> | ||
<div class="header" out:fly={{ x: 5, duration: 200 }}> | ||
<div>search failed with status {results.status}</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<div>search failed with status {results.status}</div> | |
<div>hmm ... having trouble reaching the search service ({results.status}). Reach out on #glam if this problem persists</div> |
package.json
Outdated
@@ -54,6 +54,7 @@ | |||
"d3-time-format": "2.2.3", | |||
"flexsearch": "0.6.30", | |||
"page": "1.11.6", | |||
"throttle-debounce": "^2.2.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please pin the dependency by running npm install -E throttle-debounce
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More information on why we've been pinning dependencies:
@@ -9,6 +9,15 @@ import postcss from 'rollup-plugin-postcss'; | |||
|
|||
const production = process.env.NODE_ENV === 'production'; | |||
|
|||
// We can provide this as another ENV var if desired (uses NODE_ENV currently). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we decide and remove this comment before merging?
This brings our ESLint problem count down by 12! 🎉 edit: Wait, I got that backwards. Sorry! 😆 |
src/routing/Router.svelte
Outdated
@@ -54,7 +54,7 @@ | |||
if (probeName) { | |||
store.setField('probeName', probeName); | |||
if ($probeSet) { | |||
let newProbe = $probeSet.find((p) => p.name === probeName); | |||
let newProbe = $probeSet.find((p) => p.name.toLowerCase() === probeName.toLowerCase()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to compare against probeName.toLowerCase()
? We don't support non-lowercase probe names in the URL and to avoid canonicality issues I don't think we should.
src/components/search/Search.svelte
Outdated
inputElement.blur(); | ||
store.setField('searchIsActive', false); | ||
inputElement.blur(); | ||
searchIsActive = false; | ||
} | ||
|
||
async function onKeypress(event) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small thing, but since we only need the key from the event, we could save one line by doing:
async function onKeypress({ key }) {
Personal preference one way or the other. Not a big deal.
src/components/search/Search.svelte
Outdated
import { fly } from 'svelte/transition'; | ||
import { cubicOut } from 'svelte/easing'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4:10 error 'cubicOut' is defined but never used no-unused-vars
import { fly } from 'svelte/transition'; | ||
import { cubicOut } from 'svelte/easing'; | ||
import SearchIcon from 'udgl/icons/Search.svelte'; | ||
import LineSegSpinner from 'udgl/LineSegSpinner.svelte'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Due to changes below:
6:8 error 'LineSegSpinner' is defined but never used no-unused-vars
src/components/search/Search.svelte
Outdated
} | ||
|
||
let searchResults = Promise.resolve([]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
41:5 error 'searchResults' is assigned a value but never used no-unused-vars
src/components/search/Search.svelte
Outdated
let searchResults = Promise.resolve([]); | ||
let query = ''; | ||
|
||
const handleSearchInput = throttle(SEARCH_THROTTLE_TIME, ({target: {value}}) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
44:59 error A space is required after '{' object-curly-spacing
44:68 error A space is required after '{' object-curly-spacing
44:74 error A space is required before '}' object-curly-spacing
44:75 error A space is required before '}' object-curly-spacing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
propaganda I say - will fix
@@ -7,12 +7,15 @@ import { afterUpdate } from 'svelte'; | |||
import Portal from 'udgl/Portal.svelte'; | |||
import LineSegSpinner from 'udgl/LineSegSpinner.svelte'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Due to changes below:
8:8 error 'LineSegSpinner' is defined but never used no-unused-vars
{#if $searchResults.total} | ||
<div class="header header--loaded" in:fly={{ x: -5, duration: 200 }}> | ||
<div>found {$searchResults.results.length} of | ||
{formatTotal($searchResults.total)} probes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This removal raises the following error on line 25. (GitHub won't allow me to comment on line 25.)
25:5 error 'formatTotal' is assigned a value but never used no-unused-vars
} | ||
if (key === 'Escape') { | ||
store.setField('searchIsActive', true); | ||
seachIsActive = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
61:7 error 'seachIsActive' is not defined no-undef
const handleSearchInput = throttle(SEARCH_THROTTLE_TIME, ({target: {value}}) => { | ||
query = value; | ||
searchResults = getSearchResults(query, SEARCH_RESULTS_LIMIT).then((r) => { | ||
// sort these? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are they already being sorted or is this a reference to something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're sorting them here though it's not the right approach. Plan is for PSS to give us weighted results (coming soon) so that searches found in name weigh more heavily than description/type.
src/components/search/Search.svelte
Outdated
@@ -62,15 +85,14 @@ async function onKeypress(event) { | |||
align-items: stretch; | |||
background-color: var(--input-background-color); | |||
border-radius: var(--space-1h); | |||
|
|||
position: relative; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed? I don't see a difference but I may be missing something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was with the old error notice but not anymore. Good find.
7109e6a
to
8488979
Compare
Are we still using the flexsearch package on this branch? |
CHANGELOG.md
Outdated
@@ -4,6 +4,8 @@ | |||
|
|||
- Fix issue with categorical explorer counts | |||
([#587](https://github.com/mozilla/glam/pull/587)) | |||
- Implement Probe Search Service |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implement sounds like this PR created the search service instead of updating the search to use the search service.
Supersedes #594 to merge into the main branch.