Skip to content

Commit

Permalink
fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Grace committed Aug 13, 2020
1 parent a9cf02e commit 9da43ac
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
2 changes: 2 additions & 0 deletions UPDATING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ assists people when migrating to a new version.

## Next

* [10590](https://github.com/apache/incubator-superset/pull/10590): Breaking change: this PR will convert iframe chart into dashboard markdown component, and remove all `iframe`, `separator`, and `markup` slices (and support) from Superset. If you have important data in those slices, please backup manually.

* [10567](https://github.com/apache/incubator-superset/pull/10567): Default WEBDRIVER_OPTION_ARGS are Chrome-specific. If you're using FF, should be `--headless` only

* [10241](https://github.com/apache/incubator-superset/pull/10241): change on Alpha role, users started to have access to "Annotation Layers", "Css Templates" and "Import Dashboards".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class Slice(Base):
Column("slice_id", Integer, ForeignKey("slices.id")),
)


class Dashboard(Base):
__tablename__ = "dashboards"
id = Column(Integer, primary_key=True)
Expand Down Expand Up @@ -131,18 +132,18 @@ def upgrade():
# find iframe chart position in metadata
# and replace it with markdown component
position_dict = json.loads(dashboard.position_json or "{}")
for key, value in position_dict.items():
for key, chart_position in position_dict.items():
if (
value
and isinstance(value, dict)
and value["type"] == "CHART"
and value["meta"]
and value["meta"]["chartId"] in iframe_ids
chart_position
and isinstance(chart_position, dict)
and chart_position["type"] == "CHART"
and chart_position["meta"]
and chart_position["meta"]["chartId"] in iframe_ids
):
iframe_id = value["meta"]["chartId"]
iframe_id = chart_position["meta"]["chartId"]
# make new markdown component
markdown = create_new_markdown_component(
value, iframe_urls[iframe_id]
chart_position, iframe_urls[iframe_id]
)
position_dict.pop(key)
position_dict[markdown["id"]] = markdown
Expand All @@ -162,24 +163,26 @@ def upgrade():
session.merge(dashboard)

# remove iframe, separator and markup charts
slices_to_remove = session.query(Slice).filter(
Slice.viz_type.in_(["iframe", "separator", "markup"])
).all()
slices_to_remove = (
session.query(Slice)
.filter(Slice.viz_type.in_(["iframe", "separator", "markup"]))
.all()
)
slices_ids = [slc.id for slc in slices_to_remove]

# remove dependencies first
session.query(dashboard_slices).filter(
dashboard_slices.c.slice_id.in_(slices_ids)
).delete(synchronize_session=False)

session.query(slice_user).filter(
slice_user.c.slice_id.in_(slices_ids)
).delete(synchronize_session=False)
session.query(slice_user).filter(slice_user.c.slice_id.in_(slices_ids)).delete(
synchronize_session=False
)

# remove slices
session.query(Slice).filter(
Slice.id.in_(slices_ids)
).delete(synchronize_session=False)
session.query(Slice).filter(Slice.id.in_(slices_ids)).delete(
synchronize_session=False
)

except Exception as ex:
logging.exception(f"dashboard {dashboard.id} has error: {ex}")
Expand All @@ -189,4 +192,7 @@ def upgrade():


def downgrade():
# note: this upgrade is irreversible.
# this migration removed all iframe, separator, and markup type slices,
# and Superset will not support these 3 viz_type anymore.
pass

0 comments on commit 9da43ac

Please sign in to comment.