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

justinpark 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 8b2a408dea fix(sqllab): Invalid start date (#25133)
8b2a408dea is described below

commit 8b2a408dea5516cc5163446280ad10c165da0f92
Author: JUST.in DO IT <[email protected]>
AuthorDate: Fri Sep 1 11:28:19 2023 -0700

    fix(sqllab): Invalid start date (#25133)
---
 .../src/SqlLab/components/QueryAutoRefresh/index.tsx      |  1 +
 .../src/SqlLab/components/QueryTable/index.tsx            |  2 +-
 .../src/SqlLab/components/SaveDatasetModal/index.tsx      |  2 +-
 superset-frontend/src/SqlLab/reducers/getInitialState.ts  | 15 ++++++++++++++-
 superset-frontend/src/SqlLab/reducers/sqlLab.js           |  6 ++++++
 superset-frontend/src/SqlLab/reducers/sqlLab.test.js      | 10 +++++++++-
 6 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/superset-frontend/src/SqlLab/components/QueryAutoRefresh/index.tsx 
b/superset-frontend/src/SqlLab/components/QueryAutoRefresh/index.tsx
index d8975e520c..f4808f52fd 100644
--- a/superset-frontend/src/SqlLab/components/QueryAutoRefresh/index.tsx
+++ b/superset-frontend/src/SqlLab/components/QueryAutoRefresh/index.tsx
@@ -80,6 +80,7 @@ function QueryAutoRefresh({
       SupersetClient.get({
         endpoint: `/api/v1/query/updated_since?q=${params}`,
         timeout: QUERY_TIMEOUT_LIMIT,
+        parseMethod: 'json-bigint',
       })
         .then(({ json }) => {
           if (json) {
diff --git a/superset-frontend/src/SqlLab/components/QueryTable/index.tsx 
b/superset-frontend/src/SqlLab/components/QueryTable/index.tsx
index 1ea83de58c..b5eaeb01e6 100644
--- a/superset-frontend/src/SqlLab/components/QueryTable/index.tsx
+++ b/superset-frontend/src/SqlLab/components/QueryTable/index.tsx
@@ -213,7 +213,7 @@ const QueryTable = ({
             {q.db}
           </Button>
         );
-        q.started = moment(q.startDttm).format('HH:mm:ss');
+        q.started = moment(q.startDttm).format('L HH:mm:ss');
         q.querylink = (
           <Button
             buttonSize="small"
diff --git a/superset-frontend/src/SqlLab/components/SaveDatasetModal/index.tsx 
b/superset-frontend/src/SqlLab/components/SaveDatasetModal/index.tsx
index 8ef9fa4847..eb5e025474 100644
--- a/superset-frontend/src/SqlLab/components/SaveDatasetModal/index.tsx
+++ b/superset-frontend/src/SqlLab/components/SaveDatasetModal/index.tsx
@@ -161,7 +161,7 @@ export const SaveDatasetModal = ({
   );
 
   const getDefaultDatasetName = () =>
-    `${datasource?.name || UNTITLED} ${moment().format('MM/DD/YYYY 
HH:mm:ss')}`;
+    `${datasource?.name || UNTITLED} ${moment().format('L HH:mm:ss')}`;
   const [datasetName, setDatasetName] = useState(getDefaultDatasetName());
   const [newOrOverwrite, setNewOrOverwrite] = useState(
     DatasetRadioState.SAVE_NEW,
diff --git a/superset-frontend/src/SqlLab/reducers/getInitialState.ts 
b/superset-frontend/src/SqlLab/reducers/getInitialState.ts
index 214680d53c..9867e9bf2c 100644
--- a/superset-frontend/src/SqlLab/reducers/getInitialState.ts
+++ b/superset-frontend/src/SqlLab/reducers/getInitialState.ts
@@ -130,7 +130,20 @@ export default function getInitialState({
       });
   }
 
-  const queries = { ...queries_ };
+  const queries = Object.fromEntries(
+    Object.entries(queries_ || {}).map(([queryId, query]) => [
+      queryId,
+      {
+        ...query,
+        ...(query.startDttm && {
+          startDttm: Number(query.startDttm),
+        }),
+        ...(query.endDttm && {
+          endDttm: Number(query.endDttm),
+        }),
+      },
+    ]),
+  );
 
   /**
    * If the `SQLLAB_BACKEND_PERSISTENCE` feature flag is off, or if the user
diff --git a/superset-frontend/src/SqlLab/reducers/sqlLab.js 
b/superset-frontend/src/SqlLab/reducers/sqlLab.js
index 0c7fe0e840..5b71a24036 100644
--- a/superset-frontend/src/SqlLab/reducers/sqlLab.js
+++ b/superset-frontend/src/SqlLab/reducers/sqlLab.js
@@ -626,6 +626,12 @@ export default function sqlLabReducer(state = {}, action) {
           newQueries[id] = {
             ...state.queries[id],
             ...changedQuery,
+            ...(changedQuery.startDttm && {
+              startDttm: Number(changedQuery.startDttm),
+            }),
+            ...(changedQuery.endDttm && {
+              endDttm: Number(changedQuery.endDttm),
+            }),
             // race condition:
             // because of async behavior, sql lab may still poll a couple of 
seconds
             // when it started fetching or finished rendering results
diff --git a/superset-frontend/src/SqlLab/reducers/sqlLab.test.js 
b/superset-frontend/src/SqlLab/reducers/sqlLab.test.js
index 40597c41b0..89ddc61f8c 100644
--- a/superset-frontend/src/SqlLab/reducers/sqlLab.test.js
+++ b/superset-frontend/src/SqlLab/reducers/sqlLab.test.js
@@ -364,16 +364,24 @@ describe('sqlLabReducer', () => {
       expect(Object.keys(newState.queries)).toHaveLength(0);
     });
     it('should refresh queries when polling returns new results', () => {
+      const startDttmInStr = '1693433503447.166992';
+      const endDttmInStr = '1693433503500.23132';
       newState = sqlLabReducer(
         {
           ...newState,
           queries: { abcd: {} },
         },
         actions.refreshQueries({
-          abcd: query,
+          abcd: {
+            ...query,
+            startDttm: startDttmInStr,
+            endDttm: endDttmInStr,
+          },
         }),
       );
       expect(newState.queries.abcd.changed_on).toBe(DENORMALIZED_CHANGED_ON);
+      expect(newState.queries.abcd.startDttm).toBe(Number(startDttmInStr));
+      expect(newState.queries.abcd.endDttm).toBe(Number(endDttmInStr));
       expect(newState.queriesLastUpdate).toBe(CHANGED_ON_TIMESTAMP);
     });
     it('should refresh queries when polling returns empty', () => {

Reply via email to