Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Mar 23, 2020
1 parent 2dac019 commit 935a46b
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ describe('AdhocFilter', () => {
filterOptionName: adhocFilter.filterOptionName,
sqlExpression: null,
fromFormData: false,
isExtra: false,
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Label, OverlayTrigger } from 'react-bootstrap';
import { t } from '@superset-ui/translation';

import AdhocFilterEditPopover from './AdhocFilterEditPopover';
import AdhocFilter from '../AdhocFilter';
import columnType from '../propTypes/columnType';
import adhocMetricType from '../propTypes/adhocMetricType';
import InfoTooltipWithTrigger from '../../components/InfoTooltipWithTrigger';
import { t } from '@superset-ui/translation';

const propTypes = {
adhocFilter: PropTypes.instanceOf(AdhocFilter).isRequired,
Expand Down Expand Up @@ -95,7 +95,7 @@ export default class AdhocFilterOption extends React.PureComponent {
onExited={this.onOverlayExited}
>
<div>
{adhocFilter.isExtra &&
{adhocFilter.isExtra && (
<InfoTooltipWithTrigger
icon="exclamation-triangle"
placement="top"
Expand All @@ -105,7 +105,7 @@ export default class AdhocFilterOption extends React.PureComponent {
It won't be saved when saving the chart.
`)}
/>
}
)}
<Label className="adhoc-filter-option">
<div onMouseDownCapture={this.onMouseDown}>
<span className="m-r-5 option-label">
Expand Down
4 changes: 2 additions & 2 deletions superset/examples/random_time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ def load_random_time_series_data(only_metadata=False, force=False):
slice_data = {
"granularity_sqla": "day",
"row_limit": config["ROW_LIMIT"],
"since": "1 year ago",
"until": "now",
"since": "2019-01-01",
"until": "2019-02-01",
"metric": "count",
"viz_type": "cal_heatmap",
"domain_granularity": "month",
Expand Down
2 changes: 1 addition & 1 deletion superset/utils/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ def to_adhoc(filt, expressionType="SIMPLE", clause="where"):
"clause": clause.upper(),
"expressionType": expressionType,
"filterOptionName": str(uuid.uuid4()),
"isExtra": filt.get("isExtra"),
"isExtra": True if filt.get("isExtra") is True else False,
}

if expressionType == "SIMPLE":
Expand Down
2 changes: 1 addition & 1 deletion superset/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ def save_or_overwrite_slice(
slc = Slice(owners=[g.user] if g.user else [])

form_data["adhoc_filters"] = self.remove_extra_filters(
form_data["adhoc_filters"]
form_data.get("adhoc_filters", [])
)

slc.params = json.dumps(form_data, indent=2, sort_keys=True)
Expand Down
19 changes: 14 additions & 5 deletions tests/core_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,18 +288,20 @@ def test_save_slice(self):
self.login(username="admin")
slice_name = f"Energy Sankey"
slice_id = self.get_slice(slice_name, db.session).id
copy_name = f"Test Sankey Save_{random.random()}"
copy_name_prefix = "Test Sankey"
copy_name = f"{copy_name_prefix}[save]{random.random()}"
tbl_id = self.table_ids.get("energy_usage")
new_slice_name = f"Test Sankey Overwrite_{random.random()}"
new_slice_name = f"{copy_name_prefix}[overwrite]{random.random()}"

url = (
"/superset/explore/table/{}/?slice_name={}&"
"action={}&datasource_name=energy_usage"
)

form_data = {
"adhoc_filters": [],
"viz_type": "sankey",
"groupby": "target",
"groupby": ["target"],
"metric": "sum__value",
"row_limit": 5000,
"slice_id": slice_id,
Expand All @@ -319,8 +321,9 @@ def test_save_slice(self):
self.assertEqual(slc.viz.form_data, form_data)

form_data = {
"adhoc_filters": [],
"viz_type": "sankey",
"groupby": "source",
"groupby": ["source"],
"metric": "sum__value",
"row_limit": 5000,
"slice_id": new_slice_id,
Expand All @@ -338,7 +341,13 @@ def test_save_slice(self):
self.assertEqual(slc.viz.form_data, form_data)

# Cleanup
db.session.delete(slc)
slices = (
db.session.query(Slice)
.filter(Slice.slice_name.like(copy_name_prefix + "%"))
.all()
)
for slc in slices:
db.session.delete(slc)
db.session.commit()

def test_filter_endpoint(self):
Expand Down
4 changes: 4 additions & 0 deletions tests/viz_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,7 @@ def test_filter_nulls(self, mock_uuid4):
"comparator": "",
"operator": "IS NOT NULL",
"subject": "lat",
"isExtra": False,
},
{
"clause": "WHERE",
Expand All @@ -1089,6 +1090,7 @@ def test_filter_nulls(self, mock_uuid4):
"comparator": "",
"operator": "IS NOT NULL",
"subject": "lon",
"isExtra": False,
},
],
"delimited_key": [
Expand All @@ -1099,6 +1101,7 @@ def test_filter_nulls(self, mock_uuid4):
"comparator": "",
"operator": "IS NOT NULL",
"subject": "lonlat",
"isExtra": False,
}
],
"geohash_key": [
Expand All @@ -1109,6 +1112,7 @@ def test_filter_nulls(self, mock_uuid4):
"comparator": "",
"operator": "IS NOT NULL",
"subject": "geo",
"isExtra": False,
}
],
}
Expand Down

0 comments on commit 935a46b

Please sign in to comment.