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

basic search functionality from probe search service #602

Merged
merged 1 commit into from
Jun 29, 2020
Merged

Conversation

openjck
Copy link
Contributor

@openjck openjck commented Jun 10, 2020

Supersedes #594 to merge into the main branch.

params.set('limit', resultsLimit);
params.set('select', 'name,definition,type');
params.set('product', `eq.${product}`);
params.set('type', 'neq.event');
Copy link
Member

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.

Copy link
Contributor

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.

Copy link
Contributor

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

src/state/api.js Outdated Show resolved Hide resolved
if (aHas && !bHas) return -1;
if (bHas && !aHas) return 1;
return 0;
});
Copy link
Member

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.

Copy link
Contributor

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.

Copy link
Contributor

@hamilton hamilton 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 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) {
Copy link
Contributor

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

Suggested change
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) => {
Copy link
Contributor

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

Suggested change
return await fetch(getFormattedSearchURL(queryString)).then(async (r) => {
return fetch(getFormattedSearchURL(queryString)).then(async (r) => {

Copy link
Contributor Author

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. -->
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<!-- 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}
Copy link
Contributor

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>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<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",
Copy link
Contributor Author

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.

Copy link
Contributor Author

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:

https://docs.renovatebot.com/dependency-pinning/

@@ -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).
Copy link
Contributor Author

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?

@openjck
Copy link
Contributor Author

openjck commented Jun 11, 2020

This brings our ESLint problem count down by 12! 🎉

edit: Wait, I got that backwards. Sorry! 😆

@@ -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());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

inputElement.blur();
store.setField('searchIsActive', false);
inputElement.blur();
searchIsActive = false;
}

async function onKeypress(event) {
Copy link
Contributor Author

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.

import { fly } from 'svelte/transition';
import { cubicOut } from 'svelte/easing';
Copy link
Contributor Author

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';
Copy link
Contributor Author

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

}

let searchResults = Promise.resolve([]);
Copy link
Contributor Author

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

let searchResults = Promise.resolve([]);
let query = '';

const handleSearchInput = throttle(SEARCH_THROTTLE_TIME, ({target: {value}}) => {
Copy link
Contributor Author

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

Copy link
Contributor

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';
Copy link
Contributor Author

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
Copy link
Contributor Author

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;
Copy link
Contributor Author

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?
Copy link
Contributor Author

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?

Copy link
Contributor

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.

@@ -62,15 +85,14 @@ async function onKeypress(event) {
align-items: stretch;
background-color: var(--input-background-color);
border-radius: var(--space-1h);

position: relative;
Copy link
Contributor Author

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.

Copy link
Contributor

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.

@spasovski spasovski force-pushed the pss-phase-1 branch 2 times, most recently from 7109e6a to 8488979 Compare June 12, 2020 00:28
@hamilton hamilton self-requested a review June 17, 2020 15:02
@openjck
Copy link
Contributor Author

openjck commented Jun 24, 2020

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
Copy link
Member

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.

@spasovski spasovski merged commit 3b69309 into main Jun 29, 2020
@cmharlow cmharlow deleted the pss-phase-1 branch March 18, 2022 18:39
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.

4 participants