Skip to content

Commit

Permalink
Merge branch 'master' into perm_update
Browse files Browse the repository at this point in the history
  • Loading branch information
Shengyao Qian committed May 2, 2017
2 parents d8b4b5b + 1887b5e commit ff82e8d
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 10 deletions.
3 changes: 3 additions & 0 deletions superset/assets/javascripts/SqlLab/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ export function runQuery(query) {
} else if (msg === null) {
msg = `[${textStatus}] ${errorThrown}`;
}
if (msg.indexOf('The CSRF token is missing') > 0) {
msg = 'Your session timed out, please refresh your page and try again.';
}
dispatch(queryFailed(query, msg));
},
});
Expand Down
12 changes: 10 additions & 2 deletions superset/assets/javascripts/SqlLab/components/ResultSet.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ export default class ResultSet extends React.PureComponent {
height: props.search ? props.height - RESULT_SET_CONTROLS_HEIGHT : props.height,
};
}
componentDidMount() {
// only do this the first time the component is rendered/mounted
this.reRunQueryIfSessionTimeoutErrorOnMount();
}
componentWillReceiveProps(nextProps) {
// when new results comes in, save them locally and clear in store
if (this.props.cache && (!nextProps.query.cached)
Expand All @@ -53,7 +57,6 @@ export default class ResultSet extends React.PureComponent {
this.fetchResults(nextProps.query);
}
}

getControls() {
if (this.props.search || this.props.visualize || this.props.csv) {
let csvButton;
Expand Down Expand Up @@ -132,7 +135,12 @@ export default class ResultSet extends React.PureComponent {
reFetchQueryResults(query) {
this.props.actions.reFetchQueryResults(query);
}

reRunQueryIfSessionTimeoutErrorOnMount() {
const { query } = this.props;
if (query.errorMessage && query.errorMessage.indexOf('session timed out') > 0) {
this.props.actions.runQuery(query, true);
}
}
render() {
const query = this.props.query;
const results = query.results;
Expand Down
2 changes: 1 addition & 1 deletion superset/assets/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "superset",
"version": "0.17.6-alpha.1",
"version": "0.17.6",
"description": "Superset is a data exploration platform designed to be visual, intuitive, and interactive.",
"license": "Apache-2.0",
"directories": {
Expand Down
8 changes: 4 additions & 4 deletions superset/assets/visualizations/nvd3_vis.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ const BREAKPOINTS = {
small: 340,
};

const addTotalBarValues = function (svg, chart, data, stacked) {
const format = d3.format('.3s');
const addTotalBarValues = function (svg, chart, data, stacked, axisFormat) {
const format = d3.format(axisFormat || '.3s');
const countSeriesDisplayed = data.length;

const totalStackedValues = stacked && data.length !== 0 ?
Expand Down Expand Up @@ -169,7 +169,7 @@ function nvd3Vis(slice, payload) {

if (fd.show_bar_value) {
setTimeout(function () {
addTotalBarValues(svg, chart, payload.data, stacked);
addTotalBarValues(svg, chart, payload.data, stacked, fd.y_axis_format);
}, animationTime);
}
break;
Expand Down Expand Up @@ -199,7 +199,7 @@ function nvd3Vis(slice, payload) {
}
if (fd.show_bar_value) {
setTimeout(function () {
addTotalBarValues(svg, chart, payload.data, stacked);
addTotalBarValues(svg, chart, payload.data, stacked, fd.y_axis_format);
}, animationTime);
}
if (!reduceXTicks) {
Expand Down
22 changes: 19 additions & 3 deletions superset/connectors/sqla/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from datetime import datetime
import logging
import sqlparse
from past.builtins import basestring

import pandas as pd

Expand Down Expand Up @@ -177,6 +178,11 @@ class SqlaTable(Model, BaseDatasource):
foreign_keys=[database_id])
schema = Column(String(255))
sql = Column(Text)
slices = relationship(
'Slice',
primaryjoin=(
"SqlaTable.id == foreign(Slice.datasource_id) and "
"Slice.datasource_type == 'table'"))

baselink = "tablemodelview"
export_fields = (
Expand Down Expand Up @@ -462,9 +468,19 @@ def visit_column(element, compiler, **kw):
col_obj = cols.get(col)
if col_obj:
if op in ('in', 'not in'):
values = [types.strip("'").strip('"') for types in eq]
if col_obj.is_num:
values = [utils.js_string_to_num(s) for s in values]
values = []
for v in eq:
# For backwards compatibility and edge cases
# where a column data type might have changed
if isinstance(v, basestring):
v = v.strip("'").strip('"')
if col_obj.is_num:
v = utils.string_to_num(v)

# Removing empty strings and non numeric values
# targeting numeric columns
if v is not None:
values.append(v)
cond = col_obj.sqla_col.in_(values)
if op == 'not in':
cond = ~cond
Expand Down

0 comments on commit ff82e8d

Please sign in to comment.