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

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


The following commit(s) were added to refs/heads/lyftga by this push:
     new 078a977  Pass viz type to GET requests (#7255)
078a977 is described below

commit 078a9774ce43238e8d46050f1e6cca6399a58aac
Author: Beto Dealmeida <[email protected]>
AuthorDate: Tue Apr 9 16:54:37 2019 -0700

    Pass viz type to GET requests (#7255)
    
    * Pass viz type to GET requests
    
    * Fix integration tests
---
 .../assets/cypress/integration/dashboard/controls.js     | 16 ++++++++--------
 .../assets/cypress/integration/dashboard/edit_mode.js    |  3 ++-
 superset/assets/cypress/integration/dashboard/filter.js  |  3 ++-
 superset/assets/cypress/integration/dashboard/load.js    |  3 ++-
 superset/assets/cypress/integration/dashboard/save.js    |  3 ++-
 superset/assets/src/explore/exploreUtils.js              |  3 ++-
 superset/views/utils.py                                  |  4 ++--
 7 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/superset/assets/cypress/integration/dashboard/controls.js 
b/superset/assets/cypress/integration/dashboard/controls.js
index 3e218d2..fe55815 100644
--- a/superset/assets/cypress/integration/dashboard/controls.js
+++ b/superset/assets/cypress/integration/dashboard/controls.js
@@ -32,18 +32,18 @@ export default () => describe('top-level controls', () => {
     cy.get('#app').then((data) => {
       const bootstrapData = JSON.parse(data[0].dataset.bootstrap);
       const dashboard = bootstrapData.dashboard_data;
-      const sliceIds = dashboard.slices.map(slice => (slice.slice_id));
       mapId = dashboard.slices.find(slice => (slice.form_data.viz_type === 
'world_map')).slice_id;
 
-      sliceIds
-        .forEach((id) => {
-          const sliceRequest = `getJson_${id}`;
+      dashboard.slices
+        .forEach((slice) => {
+          const sliceRequest = `getJson_${slice.slice_id}`;
           sliceRequests.push(`@${sliceRequest}`);
-          cy.route('GET', 
`/superset/explore_json/?form_data={"slice_id":${id}}`).as(sliceRequest);
+          const formData = 
`{"slice_id":${slice.slice_id},"viz_type":"${slice.form_data.viz_type}"}`;
+          cy.route('GET', 
`/superset/explore_json/?form_data=${formData}`).as(sliceRequest);
 
-          const forceRefresh = `getJson_${id}_force`;
+          const forceRefresh = `postJson_${slice.slice_id}_force`;
           forceRefreshRequests.push(`@${forceRefresh}`);
-          cy.route('POST', 
`/superset/explore_json/?form_data={"slice_id":${id}}&force=true`).as(forceRefresh);
+          cy.route('POST', 
`/superset/explore_json/?form_data={"slice_id":${slice.slice_id}}&force=true`).as(forceRefresh);
         });
     });
   });
@@ -69,7 +69,7 @@ export default () => describe('top-level controls', () => {
       .parent()
       .should('have.class', 'disabled');
 
-    cy.wait(`@getJson_${mapId}_force`);
+    cy.wait(`@postJson_${mapId}_force`);
     cy.get('#save-dash-split-button').trigger('click');
     cy.contains('Force refresh dashboard').parent().not('have.class', 
'disabled');
   });
diff --git a/superset/assets/cypress/integration/dashboard/edit_mode.js 
b/superset/assets/cypress/integration/dashboard/edit_mode.js
index d9395d2..280b6aa 100644
--- a/superset/assets/cypress/integration/dashboard/edit_mode.js
+++ b/superset/assets/cypress/integration/dashboard/edit_mode.js
@@ -28,7 +28,8 @@ export default () => describe('edit mode', () => {
       const bootstrapData = JSON.parse(data[0].dataset.bootstrap);
       const dashboard = bootstrapData.dashboard_data;
       const boxplotChartId = dashboard.slices.find(slice => 
(slice.form_data.viz_type === 'box_plot')).slice_id;
-      const boxplotRequest = 
`/superset/explore_json/?form_data={"slice_id":${boxplotChartId}}`;
+      const formData = `{"slice_id":${boxplotChartId},"viz_type":"box_plot"}`;
+      const boxplotRequest = `/superset/explore_json/?form_data=${formData}`;
       cy.route('GET', boxplotRequest).as('boxplotRequest');
     });
 
diff --git a/superset/assets/cypress/integration/dashboard/filter.js 
b/superset/assets/cypress/integration/dashboard/filter.js
index 6ec1c92..f37c8c8 100644
--- a/superset/assets/cypress/integration/dashboard/filter.js
+++ b/superset/assets/cypress/integration/dashboard/filter.js
@@ -39,7 +39,8 @@ export default () => describe('dashboard filter', () => {
   it('should apply filter', () => {
     const aliases = [];
 
-    const filterRoute = 
`/superset/explore_json/?form_data={"slice_id":${filterId}}`;
+    const formData = `{"slice_id":${filterId},"viz_type":"filter_box"}`;
+    const filterRoute = `/superset/explore_json/?form_data=${formData}`;
     cy.route('GET', filterRoute).as('fetchFilter');
     cy.wait('@fetchFilter');
     sliceIds
diff --git a/superset/assets/cypress/integration/dashboard/load.js 
b/superset/assets/cypress/integration/dashboard/load.js
index 0dbe1ff..79daa30 100644
--- a/superset/assets/cypress/integration/dashboard/load.js
+++ b/superset/assets/cypress/integration/dashboard/load.js
@@ -34,7 +34,8 @@ export default () => describe('load', () => {
       // then define routes and create alias for each requests
       slices.forEach((slice) => {
         const alias = `getJson_${slice.slice_id}`;
-        cy.route('GET', 
`/superset/explore_json/?form_data={"slice_id":${slice.slice_id}}`).as(alias);
+        const formData = 
`{"slice_id":${slice.slice_id},"viz_type":"${slice.form_data.viz_type}"}`;
+        cy.route('GET', 
`/superset/explore_json/?form_data=${formData}`).as(alias);
         aliases.push(`@${alias}`);
       });
     });
diff --git a/superset/assets/cypress/integration/dashboard/save.js 
b/superset/assets/cypress/integration/dashboard/save.js
index d144a71..1d26ac2 100644
--- a/superset/assets/cypress/integration/dashboard/save.js
+++ b/superset/assets/cypress/integration/dashboard/save.js
@@ -56,7 +56,8 @@ export default () => describe('save', () => {
     cy.wait('@copyRequest');
 
     // should have box_plot chart
-    const boxplotRequest = 
`/superset/explore_json/?form_data={"slice_id":${boxplotChartId}}`;
+    const formData = `{"slice_id":${boxplotChartId},"viz_type":"box_plot"}`;
+    const boxplotRequest = `/superset/explore_json/?form_data=${formData}`;
     cy.route('GET', boxplotRequest).as('boxplotRequest');
     cy.wait('@boxplotRequest');
     cy.get('.grid-container .box_plot').should('be.exist');
diff --git a/superset/assets/src/explore/exploreUtils.js 
b/superset/assets/src/explore/exploreUtils.js
index 4785933..eabedba 100644
--- a/superset/assets/src/explore/exploreUtils.js
+++ b/superset/assets/src/explore/exploreUtils.js
@@ -119,10 +119,11 @@ export function getExploreUrlAndPayload({
 
   // Building the querystring (search) part of the URI
   const search = uri.search(true);
-  const { slice_id, extra_filters, adhoc_filters } = formData;
+  const { slice_id, extra_filters, adhoc_filters, viz_type } = formData;
   if (slice_id) {
     const form_data = { slice_id };
     if (method === 'GET') {
+      form_data.viz_type = viz_type;
       if (extra_filters && extra_filters.length) {
         form_data.extra_filters = extra_filters;
       }
diff --git a/superset/views/utils.py b/superset/views/utils.py
index 4318141..74171d1 100644
--- a/superset/views/utils.py
+++ b/superset/views/utils.py
@@ -153,8 +153,8 @@ def get_form_data(slice_id=None, use_slice_data=False):
     slice_id = form_data.get('slice_id') or slice_id
     slc = None
 
-    # Check if form data only contains slice_id and additional filters
-    valid_keys = ['slice_id', 'extra_filters', 'adhoc_filters']
+    # Check if form data only contains slice_id, additional filters and viz 
type
+    valid_keys = ['slice_id', 'extra_filters', 'adhoc_filters', 'viz_type']
     valid_slice_id = all(key in valid_keys for key in form_data)
 
     # Include the slice_form_data if request from explore or slice calls

Reply via email to