mistercrunch commented on a change in pull request #6220: [SIP-5] Open a new 
/api/v1/query endpoint that takes query_obj
URL: 
https://github.com/apache/incubator-superset/pull/6220#discussion_r229842312
 
 

 ##########
 File path: superset/viz.py
 ##########
 @@ -63,22 +65,42 @@ class BaseViz(object):
     cache_type = 'df'
     enforce_numerical_metrics = True
 
-    def __init__(self, datasource, form_data, force=False):
-        if not datasource:
-            raise Exception(_('Viz is missing a datasource'))
+    def __init__(self, datasource, form_data, query_obj={}, force=False):
+        if datasource:
+            self.datasource = datasource
+        else:
+            datasource_dict = query_obj.get('datasource', {})
+            ds = ConnectorRegistry.get_datasource(
+                datasource_dict.get('type'), datasource_dict.get('id'), 
db.session)
+            if not ds:
+                raise Exception(_('Viz is missing a datasource'))
+            else:
+                self.datasource = ds
+
+        if not query_obj:
+            query_obj = models.query_obj_backfill(form_data)
 
-        self.datasource = datasource
         self.request = request
-        self.viz_type = form_data.get('viz_type')
-        self.form_data = form_data
 
-        self.query = ''
-        self.token = self.form_data.get(
-            'token', 'token_' + uuid.uuid4().hex[:8])
+        self.viz_type = query_obj.get('viz_type')
 
 Review comment:
   Do we need to unpack all of this? Could we just `self.query_obj = query_obj` 
?

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to