ktmud commented on a change in pull request #16469:
URL: https://github.com/apache/superset/pull/16469#discussion_r698840052
##########
File path: superset-frontend/src/SqlLab/reducers/sqlLab.js
##########
@@ -520,7 +520,20 @@ export default function sqlLabReducer(state = {}, action) {
if (changedQuery.changedOn > queriesLastUpdate) {
queriesLastUpdate = changedQuery.changedOn;
}
- newQueries[id] = { ...state.queries[id], ...changedQuery };
+ const prevState = state.queries[id]?.state;
+ const currentState = changedQuery.state;
+ newQueries[id] = {
+ ...state.queries[id],
+ ...changedQuery,
+ // race condition:
+ // because of async behavior, sql lab may still poll a couple of
seconds
+ // when it started fetching or finished rendering results
+ state:
+ currentState === 'success' &&
+ ['fetching', 'success'].includes(prevState)
+ ? prevState
+ : currentState,
Review comment:
Could this be simplified to `state: currentState == 'fetching' &&
prevState === 'success' ? 'success' : currentState`?
##########
File path: superset-frontend/src/SqlLab/reducers/sqlLab.js
##########
@@ -520,7 +520,20 @@ export default function sqlLabReducer(state = {}, action) {
if (changedQuery.changedOn > queriesLastUpdate) {
queriesLastUpdate = changedQuery.changedOn;
}
- newQueries[id] = { ...state.queries[id], ...changedQuery };
+ const prevState = state.queries[id]?.state;
+ const currentState = changedQuery.state;
+ newQueries[id] = {
+ ...state.queries[id],
+ ...changedQuery,
+ // race condition:
+ // because of async behavior, sql lab may still poll a couple of
seconds
+ // when it started fetching or finished rendering results
+ state:
+ currentState === 'success' &&
+ ['fetching', 'success'].includes(prevState)
+ ? prevState
+ : currentState,
Review comment:
Could this be simplified to `state: currentState == 'fetching' &&
prevState === 'success' ? 'success' : currentState`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]