Skip to content

Commit

Permalink
#[UIC-2110]:updated sliceoptions in slice formdata (#244)
Browse files Browse the repository at this point in the history
* fix(slice):not saved sliceoptions in subscriberlayer and removed  existing sliceoptions from subscriberlayer while importing dashboard

not saved sliceoptions in subscriberlayer and removed  existing sliceoptions from subscriberlayer while importing dashboard
sliceoptions will be fetch on runtime

UIC-2110

* fix(slice):did review changes

did review changes

UIC-2110
  • Loading branch information
jitendra-kumawat authored Sep 17, 2019
1 parent d79c24b commit 50c4e7f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ export default class SubscriberLayer extends React.PureComponent {
const subscription = {};

Object.keys(this.state).forEach((k) => {
if (this.state[k] !== null) {
// add checks of not dump sliceOptions in formdata ,it will fetch runtime always
if ( k != 'sliceOptions' && this.state[k] !== null ) {
subscription[k] = this.state[k];
}
});
Expand Down
11 changes: 11 additions & 0 deletions superset/utils/dashboard_import_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,23 @@
from superset.models.core import Dashboard
from superset.utils.core import decode_dashboards

def update_slice_options(slices):
# remove sliceOptions before dump to db ,it will fetch on runtime
for slice in slices:
params = json.loads(slice.params)
for subscriber_layer in params['subscriber_layers']:
if 'sliceOptions' in subscriber_layer:
subscriber_layer['sliceOptions'] = []
slice.params = json.dumps(params)

def dashboard_json(data):
return json.loads(data, object_hook=decode_dashboards)

def import_dashboard_json(session, data, import_time=None):
current_tt = int(time.time())
import_time = current_tt if import_time is None else import_time
dashboard = data['dashboards'][0]
update_slice_options(dashboard.slices)
dash_id = Dashboard.import_obj(
dashboard, import_time=import_time)
session.commit()
Expand All @@ -44,6 +54,7 @@ def import_dashboards(session, data_stream, import_time=None):
type(table).import_obj(table, import_time=import_time)
session.commit()
for dashboard in data['dashboards']:
update_slice_options(dashboard.slices)
Dashboard.import_obj(
dashboard, import_time=import_time)
session.commit()
Expand Down

0 comments on commit 50c4e7f

Please sign in to comment.