From af55dfcc4d175eb5f9cb77f0afdbc34d2e56c66e Mon Sep 17 00:00:00 2001 From: Jason Davis <@dropbox.com> Date: Tue, 4 Aug 2020 14:33:16 -0700 Subject: [PATCH 1/2] make urls user friendly --- superset/tasks/schedules.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/superset/tasks/schedules.py b/superset/tasks/schedules.py index 78793b9680119..90b2849d132bf 100644 --- a/superset/tasks/schedules.py +++ b/superset/tasks/schedules.py @@ -580,13 +580,12 @@ def deliver_alert(alert_id: int, recipients: Optional[str] = None) -> None: "Superset.slice", slice_id=alert.slice.id, standalone="true" ) screenshot = ChartScreenshot(chart_url, alert.slice.digest) - cache_key = screenshot.cache_key() - image_url = get_url_path( - "ChartRestApi.screenshot", pk=alert.slice.id, digest=cache_key + image_url = _get_url_path( + "Superset.slice", user_friendly=True, slice_id=alert.slice.id, standalone="true" ) - standalone_index = chart_url.find("/?standalone=true") + standalone_index = image_url.find("/?standalone=true") if standalone_index != -1: - image_url = chart_url[:standalone_index] + image_url = image_url[:standalone_index] user = security_manager.find_user(current_app.config["THUMBNAIL_SELENIUM_USER"]) img_data = screenshot.compute_and_cache( @@ -605,7 +604,7 @@ def deliver_alert(alert_id: int, recipients: Optional[str] = None) -> None: images = {"screenshot": img_data} body = render_template( "email/alert.txt", - alert_url=get_url_path("AlertModelView.show", pk=alert.id), + alert_url=_get_url_path("AlertModelView.show", user_friendly=True, pk=alert.id), label=alert.label, sql=alert.sql, image_url=image_url, From 879cd9b8b159c335c82bb1ad42452bf3eb1b6adc Mon Sep 17 00:00:00 2001 From: Jason Davis <@dropbox.com> Date: Tue, 4 Aug 2020 14:42:05 -0700 Subject: [PATCH 2/2] formatting --- superset/tasks/schedules.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/superset/tasks/schedules.py b/superset/tasks/schedules.py index 90b2849d132bf..0a74ddf882480 100644 --- a/superset/tasks/schedules.py +++ b/superset/tasks/schedules.py @@ -581,7 +581,10 @@ def deliver_alert(alert_id: int, recipients: Optional[str] = None) -> None: ) screenshot = ChartScreenshot(chart_url, alert.slice.digest) image_url = _get_url_path( - "Superset.slice", user_friendly=True, slice_id=alert.slice.id, standalone="true" + "Superset.slice", + user_friendly=True, + slice_id=alert.slice.id, + standalone="true", ) standalone_index = image_url.find("/?standalone=true") if standalone_index != -1: