Skip to content

Commit

Permalink
values_for_column row limit config and cancel active filter request
Browse files Browse the repository at this point in the history
  • Loading branch information
Kalyan Kanuri authored and Mogball committed Nov 28, 2017
1 parent 2851979 commit 02d9922
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default class FilterControl extends React.Component {
}));
this.state = {
filters: initialFilters,
activeRequest: null,
};
}

Expand All @@ -45,16 +46,20 @@ export default class FilterControl extends React.Component {
newStateFilters[index].valuesLoading = true;
return { filters: newStateFilters };
});
$.ajax({
type: 'GET',
url: `/superset/filter/${datasource.type}/${datasource.id}/${col}/`,
success: (data) => {
this.setState((prevState) => {
const newStateFilters = Object.assign([], prevState.filters);
newStateFilters[index] = { valuesLoading: false, valueChoices: data };
return { filters: newStateFilters };
});
},
// if there is an outstanding request to fetch values, cancel it.
if (this.state.activeRequest) this.state.activeRequest.abort();
this.setState({
activeRequest: $.ajax({
type: 'GET',
url: `/superset/filter/${datasource.type}/${datasource.id}/${col}/`,
success: (data) => {
this.setState((prevState) => {
const newStateFilters = Object.assign([], prevState.filters);
newStateFilters[index] = { valuesLoading: false, valueChoices: data };
return { filters: newStateFilters };
});
},
}),
});
}
}
Expand Down
2 changes: 2 additions & 0 deletions superset/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@

ROW_LIMIT = 50000
VIZ_ROW_LIMIT = 10000
# max rows retrieved by filter select auto complete
FILTER_SELECT_ROW_LIMIT = 10000
SUPERSET_WORKERS = 2
SUPERSET_CELERY_WORKERS = 32

Expand Down
5 changes: 4 additions & 1 deletion superset/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,10 @@ def filter(self, datasource_type, datasource_id, column):
return json_error_response(DATASOURCE_ACCESS_ERR)

payload = json.dumps(
datasource.values_for_column(column),
datasource.values_for_column(
column,
config.get('FILTER_SELECT_ROW_LIMIT', 10000),
),
default=utils.json_int_dttm_ser)
return json_success(payload)

Expand Down

0 comments on commit 02d9922

Please sign in to comment.