You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2018/08/02 06:10:49 UTC

[GitHub] mistercrunch closed pull request #5536: Replace metadata refresh stacktrace with danger flash

mistercrunch closed pull request #5536: Replace metadata refresh stacktrace with danger flash
URL: https://github.com/apache/incubator-superset/pull/5536
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/superset/connectors/druid/views.py b/superset/connectors/druid/views.py
index 7e50536195..5e5ba0da93 100644
--- a/superset/connectors/druid/views.py
+++ b/superset/connectors/druid/views.py
@@ -21,7 +21,7 @@
 from superset.connectors.connector_registry import ConnectorRegistry
 from superset.views.base import (
     BaseSupersetView, DatasourceFilter, DeleteMixin,
-    get_datasource_exist_error_mgs, ListWidgetWithCheckboxes, SupersetModelView,
+    get_datasource_exist_error_msg, ListWidgetWithCheckboxes, SupersetModelView,
     validate_json, YamlExportMixin,
 )
 from . import models
@@ -284,7 +284,7 @@ def pre_add(self, datasource):
                         datasource.cluster.id)
             )
             if db.session.query(query.exists()).scalar():
-                raise Exception(get_datasource_exist_error_mgs(
+                raise Exception(get_datasource_exist_error_msg(
                     datasource.full_name))
 
     def post_add(self, datasource):
diff --git a/superset/connectors/sqla/views.py b/superset/connectors/sqla/views.py
index cceee9a8c0..01c68c7ea3 100644
--- a/superset/connectors/sqla/views.py
+++ b/superset/connectors/sqla/views.py
@@ -18,7 +18,7 @@
 from superset import appbuilder, db, security_manager, utils
 from superset.connectors.base.views import DatasourceModelView
 from superset.views.base import (
-    DatasourceFilter, DeleteMixin, get_datasource_exist_error_mgs,
+    DatasourceFilter, DeleteMixin, get_datasource_exist_error_msg,
     ListWidgetWithCheckboxes, SupersetModelView, YamlExportMixin,
 )
 from . import models
@@ -252,7 +252,7 @@ def pre_add(self, table):
                 models.SqlaTable.database_id == table.database.id)
             if db.session.query(table_query.exists()).scalar():
                 raise Exception(
-                    get_datasource_exist_error_mgs(table.full_name))
+                    get_datasource_exist_error_msg(table.full_name))
 
         # Fail before adding if the table can't be found
         try:
@@ -300,12 +300,26 @@ def edit(self, pk):
     def refresh(self, tables):
         if not isinstance(tables, list):
             tables = [tables]
+        successes = []
+        failures = []
         for t in tables:
-            t.fetch_metadata()
-        msg = _(
-            'Metadata refreshed for the following table(s): %(tables)s',
-            tables=', '.join([t.table_name for t in tables]))
-        flash(msg, 'info')
+            try:
+                t.fetch_metadata()
+                successes.append(t)
+            except Exception:
+                failures.append(t)
+
+        if len(successes) > 0:
+            success_msg = _(
+                'Metadata refreshed for the following table(s): %(tables)s',
+                tables=', '.join([t.table_name for t in successes]))
+            flash(success_msg, 'info')
+        if len(failures) > 0:
+            failure_msg = _(
+                'Unable to retrieve metadata for the following table(s): %(tables)s',
+                tables=', '.join([t.table_name for t in failures]))
+            flash(failure_msg, 'danger')
+
         return redirect('/tablemodelview/list/')
 
 
diff --git a/superset/views/base.py b/superset/views/base.py
index d3fd1a4e06..ef519ab1a1 100644
--- a/superset/views/base.py
+++ b/superset/views/base.py
@@ -77,7 +77,7 @@ def wraps(self, *args, **kwargs):
     return functools.update_wrapper(wraps, f)
 
 
-def get_datasource_exist_error_mgs(full_name):
+def get_datasource_exist_error_msg(full_name):
     return __('Datasource %(name)s already exists', name=full_name)
 
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org