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

Fix a bug from swagger-codegen #43

Merged
merged 4 commits into from
Mar 29, 2018
Merged

Fix a bug from swagger-codegen #43

merged 4 commits into from
Mar 29, 2018

Conversation

alahwa
Copy link
Contributor

@alahwa alahwa commented Mar 28, 2018

The recent swagger-codegen update broke FacetedSearch. The API layer enforces that we provide queryParams as an array, not as comma separated values (which we were doing anyway) so we'll let the API layer handle that.

@@ -107,15 +107,15 @@ class App extends Component {
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Github won't let me leave a comment on line 34. "search" isn't used elsewhere, so can line 34 change to

// Map from facet name to list of facet values
this.filterMap = new Map();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

ui/src/App.js Outdated
@@ -107,15 +107,15 @@ class App extends Component {
}

serializeFilters(searchFilters) {
Copy link
Contributor

Choose a reason for hiding this comment

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

filterMapToArray()
   """Converts filter map to array of filter strings.

   Args:
     filterMap: map from filter name to list of filter values

   Returns:
     An array of filter strings, where each string looks like "Gender=male".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

ui/src/App.js Outdated
@@ -107,15 +107,15 @@ class App extends Component {
}

serializeFilters(searchFilters) {
let filterStr = [];
let filterList = [];
searchFilters.forEach((values, key) => {
if (values.length > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Throw an error if values.length == 0, or don't check

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 is not an error case, check > uncheck will result in an initialized key corresponding to an empty array, in which case we'll just ignore it rather than provide an empty filter.

ui/src/App.js Outdated
@@ -107,15 +107,15 @@ class App extends Component {
}

serializeFilters(searchFilters) {
let filterStr = [];
let filterList = [];
Copy link
Contributor

Choose a reason for hiding this comment

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

filterArr or filterArray

Python has lists but I think these are arrays in js

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

ui/src/App.js Outdated
}
}
});
return filterStr.join(',');
return filterList;
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Adding comment here so you can reply to it if you want.

I git checkout and I see this bug:

  • Check a facet. Things work as expected.
  • Uncheck same facet. Get console error and UI doesn't update.

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 is a separate issue which I have a followup PR staged for.

ui/src/App.js Outdated
@@ -31,6 +31,7 @@ class App extends Component {
});
}
}.bind(this);
// Map of facetName:[facetValues] pairs
Copy link
Contributor

Choose a reason for hiding this comment

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

"pairs" is confusing -- where is the pair?

// Map from facet name to a list of facet values.

Same on line 113

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

ui/src/App.js Outdated
@@ -31,6 +31,7 @@ class App extends Component {
});
}
}.bind(this);
// Map of facetName:[facetValues] pairs
this.searchFilters = new Map();
Copy link
Contributor

Choose a reason for hiding this comment

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

Can searchFilters be renamed to filterMap?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

ui/src/App.js Outdated
*/
filterMapToArray(filterMap) {
let filterArray = [];
filterMap.forEach((values, key) => {
if (values.length > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

// Scenario where there are no values for a key:
// A single value is checked for a facet. The value is unchecked.
// The facet name will still be a key in filterMap, but there will be no values.
if (values.length > 0) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@alahwa alahwa merged commit 040fbe4 into master Mar 29, 2018
@alahwa alahwa deleted the ah/bugfix branch March 29, 2018 01:14
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.

2 participants