Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sqllab): Invalid start date #25133

Merged
merged 5 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ const QueryTable = ({
{q.db}
</Button>
);
q.started = moment(q.startDttm).format('HH:mm:ss');
q.started = moment(q.startDttm).format('ll HH:mm:ss');
q.querylink = (
<Button
buttonSize="small"
Expand Down
15 changes: 14 additions & 1 deletion superset-frontend/src/SqlLab/reducers/getInitialState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions superset-frontend/src/SqlLab/reducers/sqlLab.js
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,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
Expand Down
10 changes: 9 additions & 1 deletion superset-frontend/src/SqlLab/reducers/sqlLab.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down