You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by vi...@apache.org on 2023/06/16 14:38:34 UTC

[superset] branch master updated: fix(sql-lab): remove redundant onChange schema property (#24422)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 20e0036336 fix(sql-lab): remove redundant onChange schema property (#24422)
20e0036336 is described below

commit 20e00363365780c37fefe60311321c41a81c5ee9
Author: Ville Brofeldt <33...@users.noreply.github.com>
AuthorDate: Fri Jun 16 17:38:26 2023 +0300

    fix(sql-lab): remove redundant onChange schema property (#24422)
---
 .../src/SqlLab/components/SouthPane/SouthPane.test.jsx            | 8 ++++----
 superset-frontend/src/SqlLab/fixtures.ts                          | 3 ---
 superset-frontend/src/SqlLab/reducers/sqlLab.js                   | 5 +++--
 superset/charts/schemas.py                                        | 2 +-
 superset/explore/schemas.py                                       | 2 +-
 superset/models/sql_lab.py                                        | 1 -
 superset/sqllab/schemas.py                                        | 3 +--
 tests/integration_tests/queries/api_tests.py                      | 1 -
 8 files changed, 10 insertions(+), 15 deletions(-)

diff --git a/superset-frontend/src/SqlLab/components/SouthPane/SouthPane.test.jsx b/superset-frontend/src/SqlLab/components/SouthPane/SouthPane.test.jsx
index 519e729c41..b06488e3b7 100644
--- a/superset-frontend/src/SqlLab/components/SouthPane/SouthPane.test.jsx
+++ b/superset-frontend/src/SqlLab/components/SouthPane/SouthPane.test.jsx
@@ -61,7 +61,7 @@ const store = mockStore({
     queries: {
       LCly_kkIN: {
         cached: false,
-        changedOn: Date.now(),
+        changed_on: new Date().toISOString(),
         db: 'main',
         dbId: 1,
         id: 'LCly_kkIN',
@@ -71,7 +71,7 @@ const store = mockStore({
       },
       lXJa7F9_r: {
         cached: false,
-        changedOn: 1559238500401,
+        changed_on: new Date(1559238500401).toISOString(),
         db: 'main',
         dbId: 1,
         id: 'lXJa7F9_r',
@@ -80,7 +80,7 @@ const store = mockStore({
       },
       '2g2_iRFMl': {
         cached: false,
-        changedOn: 1559238506925,
+        changed_on: new Date(1559238506925).toISOString(),
         db: 'main',
         dbId: 1,
         id: '2g2_iRFMl',
@@ -89,7 +89,7 @@ const store = mockStore({
       },
       erWdqEWPm: {
         cached: false,
-        changedOn: 1559238516395,
+        changed_on: new Date(1559238516395).toISOString(),
         db: 'main',
         dbId: 1,
         id: 'erWdqEWPm',
diff --git a/superset-frontend/src/SqlLab/fixtures.ts b/superset-frontend/src/SqlLab/fixtures.ts
index 18faaebea2..ebfd018885 100644
--- a/superset-frontend/src/SqlLab/fixtures.ts
+++ b/superset-frontend/src/SqlLab/fixtures.ts
@@ -217,7 +217,6 @@ export const queries = [
     progress: 100,
     startDttm: 1476910566092.96,
     state: QueryState.SUCCESS,
-    changedOn: 1476910566000,
     tempTable: null,
     userId: 1,
     executedSql: null,
@@ -276,7 +275,6 @@ export const queries = [
     progress: 100,
     startDttm: 1476910570802.2,
     state: QueryState.SUCCESS,
-    changedOn: 1476910572000,
     tempTable: null,
     userId: 1,
     executedSql:
@@ -310,7 +308,6 @@ export const queryWithNoQueryLimit = {
   progress: 100,
   startDttm: 1476910566092.96,
   state: QueryState.SUCCESS,
-  changedOn: 1476910566000,
   tempTable: null,
   userId: 1,
   executedSql: null,
diff --git a/superset-frontend/src/SqlLab/reducers/sqlLab.js b/superset-frontend/src/SqlLab/reducers/sqlLab.js
index 6dcd07a77b..915bb3f6b7 100644
--- a/superset-frontend/src/SqlLab/reducers/sqlLab.js
+++ b/superset-frontend/src/SqlLab/reducers/sqlLab.js
@@ -614,8 +614,9 @@ export default function sqlLabReducer(state = {}, action) {
           (state.queries[id].state !== QueryState.STOPPED &&
             state.queries[id].state !== QueryState.FAILED)
         ) {
-          if (changedQuery.changedOn > queriesLastUpdate) {
-            queriesLastUpdate = changedQuery.changedOn;
+          const changedOn = Date.parse(changedQuery.changed_on);
+          if (changedOn > queriesLastUpdate) {
+            queriesLastUpdate = changedOn;
           }
           const prevState = state.queries[id]?.state;
           const currentState = changedQuery.state;
diff --git a/superset/charts/schemas.py b/superset/charts/schemas.py
index 0ba4084c89..a5e0a6c44c 100644
--- a/superset/charts/schemas.py
+++ b/superset/charts/schemas.py
@@ -164,7 +164,7 @@ class ChartEntityResponseSchema(Schema):
     id = fields.Integer(metadata={"description": id_description})
     slice_name = fields.String(metadata={"description": slice_name_description})
     cache_timeout = fields.Integer(metadata={"description": cache_timeout_description})
-    changed_on = fields.String(metadata={"description": changed_on_description})
+    changed_on = fields.DateTime(metadata={"description": changed_on_description})
     description = fields.String(metadata={"description": description_description})
     description_markeddown = fields.String(
         metadata={"description": description_markeddown_description}
diff --git a/superset/explore/schemas.py b/superset/explore/schemas.py
index f0060360cf..37044c0394 100644
--- a/superset/explore/schemas.py
+++ b/superset/explore/schemas.py
@@ -114,7 +114,7 @@ class SliceSchema(Schema):
     certified_by = fields.String(
         metadata={"description": "Person or group that has certified this dashboard."}
     )
-    changed_on = fields.String(
+    changed_on = fields.DateTime(
         metadata={"description": "Timestamp of the last modification."}
     )
     changed_on_humanized = fields.String(
diff --git a/superset/models/sql_lab.py b/superset/models/sql_lab.py
index a566f75b43..aeb4ba39df 100644
--- a/superset/models/sql_lab.py
+++ b/superset/models/sql_lab.py
@@ -135,7 +135,6 @@ class Query(
 
     def to_dict(self) -> dict[str, Any]:
         return {
-            "changedOn": self.changed_on,
             "changed_on": self.changed_on.isoformat(),
             "dbId": self.database_id,
             "db": self.database.database_name if self.database else None,
diff --git a/superset/sqllab/schemas.py b/superset/sqllab/schemas.py
index 30274d6de9..d388dc0353 100644
--- a/superset/sqllab/schemas.py
+++ b/superset/sqllab/schemas.py
@@ -58,8 +58,7 @@ class ExecutePayloadSchema(Schema):
 
 
 class QueryResultSchema(Schema):
-    changedOn = fields.DateTime()
-    changed_on = fields.String()
+    changed_on = fields.DateTime()
     dbId = fields.Integer()
     db = fields.String()  # pylint: disable=invalid-name
     endDttm = fields.Float()
diff --git a/tests/integration_tests/queries/api_tests.py b/tests/integration_tests/queries/api_tests.py
index b3b291cf96..c58817c8e0 100644
--- a/tests/integration_tests/queries/api_tests.py
+++ b/tests/integration_tests/queries/api_tests.py
@@ -439,7 +439,6 @@ class TestQueryApi(SupersetTestCase):
         for key, value in data["result"][0].items():
             # We can't assert timestamp
             if key not in (
-                "changedOn",
                 "changed_on",
                 "end_time",
                 "start_running_time",