Skip to content
Snippets Groups Projects
Commit 3dcc78e6 authored by esikkala's avatar esikkala
Browse files

Handle empty facet value responses

parent 49cf1c12
No related branches found
No related tags found
No related merge requests found
......@@ -38,6 +38,7 @@ class DateSliderFacet extends Component {
}
handleSliderOnChange = values => {
// console.log(this.YearToISOString(values[0]))
this.props.updateFacetOption({
facetClass: this.props.facetClass,
facetID: this.props.facetID,
......@@ -56,6 +57,11 @@ class DateSliderFacet extends Component {
return year;
}
// YearToISOString = year => {
// let str = null;
// console.log(year)
// }
render() {
const { classes, someFacetIsFetching } = this.props;
const { isFetching, min, max } = this.props.facet;
......
......@@ -215,9 +215,9 @@ const fetchFacetEpic = (action$, state$) => action$.pipe(
map(res => updateFacetValues({
facetClass: facetClass,
id: facetID,
distinctValueCount: res.distinctValueCount || null,
values: res.values || null,
flatValues: res.flatValues || null,
distinctValueCount: res.distinctValueCount || 0,
values: res.values || [],
flatValues: res.flatValues || [],
min: res.min || null,
max: res.max || null
})),
......
......@@ -209,8 +209,8 @@ export const updateFacetValues = (state, action) => {
...state.facets,
[ action.id ]: {
...state.facets[action.id],
distinctValueCount: action.distinctValueCount || null,
values: action.values || null,
distinctValueCount: action.distinctValueCount || 0,
values: action.values || [],
flatValues: action.flatValues || [],
isFetching: false
}
......
......@@ -23,8 +23,8 @@ export const INITIAL_STATE = {
distinctValueCount: 0,
values: [],
flatValues: [],
//sortBy: 'instanceCount',
//sortDirection: 'desc',
sortBy: null,
sortDirection: null,
sortButton: false,
spatialFilterButton: false,
isFetching: false,
......@@ -56,9 +56,9 @@ export const INITIAL_STATE = {
// id: 'productionTimespan',
// label: 'Production date',
// //predicate: defined in backend
// distinctValueCount: null,
// values: null,
// flatValues: null,
// distinctValueCount: 0,
// values: [],
// flatValues: [],
// sortBy: null,
// sortDirection: null,
// sortButton: false,
......
......@@ -106,7 +106,6 @@ export const getFacet = ({
q = q.replace('<SELECTED_VALUES_NO_HITS>', selectedNoHitsBlock);
q = q.replace('<FACET_VALUE_FILTER>', facetConfig.facetValueFilter);
q = q.replace('<PARENTS>', parentBlock);
// TODO: order only when facet type is list
if (facetConfig.type === 'list') {
q = q.replace('<ORDER_BY>', `ORDER BY ${sortDirection}(?${sortBy})` );
} else {
......
......@@ -23,7 +23,10 @@ export const mapCount = sparqlBindings => {
};
export const mapFacet = sparqlBindings => {
const results = mapFacetValues(sparqlBindings);
let results = [];
if (sparqlBindings.length > 0) {
results = mapFacetValues(sparqlBindings);
}
return {
distinctValueCount: results.length,
values: results
......
......@@ -18,8 +18,7 @@ export const runSelectQuery = async (query, endpoint, resultMapper) => {
url: endpoint,
data: querystring.stringify({ query }),
});
const { bindings } = response.data.results;
return bindings.length === 0 ? [] : resultMapper(bindings);
return resultMapper(response.data.results.bindings);
} catch(error) {
if (error.response) {
// The request was made and the server responded with a status code
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment