This is an automated email from the ASF dual-hosted git repository.

bkyryliuk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 0d91b3e  fix: make SQL-based alert email links user friendly (#10519)
0d91b3e is described below

commit 0d91b3ee6e0a77af3f76e209d88ff5f10d7e9176
Author: Jason Davis <[email protected]>
AuthorDate: Tue Aug 4 15:45:38 2020 -0700

    fix: make SQL-based alert email links user friendly (#10519)
    
    * make urls user friendly
    
    * formatting
    
    Co-authored-by: Jason Davis <@dropbox.com>
---
 superset/tasks/schedules.py | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/superset/tasks/schedules.py b/superset/tasks/schedules.py
index 78793b9..0a74ddf 100644
--- a/superset/tasks/schedules.py
+++ b/superset/tasks/schedules.py
@@ -580,13 +580,15 @@ 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 +607,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,

Reply via email to