mirror of
https://github.com/apache/superset.git
synced 2024-09-12 08:39:45 -04:00
fix(sqllab): Invalid start date (#25133)
This commit is contained in:
parent
e391a1b49e
commit
8b2a408dea
@ -80,6 +80,7 @@ function QueryAutoRefresh({
|
|||||||
SupersetClient.get({
|
SupersetClient.get({
|
||||||
endpoint: `/api/v1/query/updated_since?q=${params}`,
|
endpoint: `/api/v1/query/updated_since?q=${params}`,
|
||||||
timeout: QUERY_TIMEOUT_LIMIT,
|
timeout: QUERY_TIMEOUT_LIMIT,
|
||||||
|
parseMethod: 'json-bigint',
|
||||||
})
|
})
|
||||||
.then(({ json }) => {
|
.then(({ json }) => {
|
||||||
if (json) {
|
if (json) {
|
||||||
|
@ -213,7 +213,7 @@ const QueryTable = ({
|
|||||||
{q.db}
|
{q.db}
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
q.started = moment(q.startDttm).format('HH:mm:ss');
|
q.started = moment(q.startDttm).format('L HH:mm:ss');
|
||||||
q.querylink = (
|
q.querylink = (
|
||||||
<Button
|
<Button
|
||||||
buttonSize="small"
|
buttonSize="small"
|
||||||
|
@ -161,7 +161,7 @@ export const SaveDatasetModal = ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const getDefaultDatasetName = () =>
|
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 [datasetName, setDatasetName] = useState(getDefaultDatasetName());
|
||||||
const [newOrOverwrite, setNewOrOverwrite] = useState(
|
const [newOrOverwrite, setNewOrOverwrite] = useState(
|
||||||
DatasetRadioState.SAVE_NEW,
|
DatasetRadioState.SAVE_NEW,
|
||||||
|
@ -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
|
* If the `SQLLAB_BACKEND_PERSISTENCE` feature flag is off, or if the user
|
||||||
|
@ -626,6 +626,12 @@ export default function sqlLabReducer(state = {}, action) {
|
|||||||
newQueries[id] = {
|
newQueries[id] = {
|
||||||
...state.queries[id],
|
...state.queries[id],
|
||||||
...changedQuery,
|
...changedQuery,
|
||||||
|
...(changedQuery.startDttm && {
|
||||||
|
startDttm: Number(changedQuery.startDttm),
|
||||||
|
}),
|
||||||
|
...(changedQuery.endDttm && {
|
||||||
|
endDttm: Number(changedQuery.endDttm),
|
||||||
|
}),
|
||||||
// race condition:
|
// race condition:
|
||||||
// because of async behavior, sql lab may still poll a couple of seconds
|
// because of async behavior, sql lab may still poll a couple of seconds
|
||||||
// when it started fetching or finished rendering results
|
// when it started fetching or finished rendering results
|
||||||
|
@ -364,16 +364,24 @@ describe('sqlLabReducer', () => {
|
|||||||
expect(Object.keys(newState.queries)).toHaveLength(0);
|
expect(Object.keys(newState.queries)).toHaveLength(0);
|
||||||
});
|
});
|
||||||
it('should refresh queries when polling returns new results', () => {
|
it('should refresh queries when polling returns new results', () => {
|
||||||
|
const startDttmInStr = '1693433503447.166992';
|
||||||
|
const endDttmInStr = '1693433503500.23132';
|
||||||
newState = sqlLabReducer(
|
newState = sqlLabReducer(
|
||||||
{
|
{
|
||||||
...newState,
|
...newState,
|
||||||
queries: { abcd: {} },
|
queries: { abcd: {} },
|
||||||
},
|
},
|
||||||
actions.refreshQueries({
|
actions.refreshQueries({
|
||||||
abcd: query,
|
abcd: {
|
||||||
|
...query,
|
||||||
|
startDttm: startDttmInStr,
|
||||||
|
endDttm: endDttmInStr,
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
expect(newState.queries.abcd.changed_on).toBe(DENORMALIZED_CHANGED_ON);
|
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);
|
expect(newState.queriesLastUpdate).toBe(CHANGED_ON_TIMESTAMP);
|
||||||
});
|
});
|
||||||
it('should refresh queries when polling returns empty', () => {
|
it('should refresh queries when polling returns empty', () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user