Skip to content

Commit

Permalink
fix(sqllab): Invalid start date
Browse files Browse the repository at this point in the history
  • Loading branch information
justinpark committed Aug 30, 2023
1 parent 66e2807 commit bd91059
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
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

0 comments on commit bd91059

Please sign in to comment.