-
Notifications
You must be signed in to change notification settings - Fork 906
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
Keep previous query result if current query result in error #8863
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
fix: | ||
- Keep previous query result if current query result in error ([#8863](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8863)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,8 +84,13 @@ export default function DiscoverCanvas({ setHeaderActionMenu, history, optionalR | |
if (next.bucketInterval && next.bucketInterval !== fetchState.bucketInterval) | ||
shouldUpdateState = true; | ||
if (next.chartData && next.chartData !== fetchState.chartData) shouldUpdateState = true; | ||
// we still want to show rows from the previous query while current query is loading | ||
if (next.status !== ResultStatus.LOADING && next.rows && next.rows !== fetchState.rows) { | ||
// we still want to show rows from the previous query while current query is loading or the current query results in error | ||
if ( | ||
next.status !== ResultStatus.LOADING && | ||
next.status !== ResultStatus.ERROR && | ||
next.rows && | ||
next.rows !== fetchState.rows | ||
) { | ||
shouldUpdateState = true; | ||
setRows(next.rows); | ||
} | ||
|
@@ -152,20 +157,13 @@ export default function DiscoverCanvas({ setHeaderActionMenu, history, optionalR | |
timeFieldName={timeField} | ||
/> | ||
)} | ||
{fetchState.status === ResultStatus.ERROR && ( | ||
<DiscoverNoResults | ||
queryString={data.query.queryString} | ||
query={data.query.queryString.getQuery()} | ||
savedQuery={data.query.savedQueries} | ||
timeFieldName={timeField} | ||
/> | ||
)} | ||
{fetchState.status === ResultStatus.UNINITIALIZED && ( | ||
<DiscoverUninitialized onRefresh={() => refetch$.next()} /> | ||
)} | ||
{fetchState.status === ResultStatus.LOADING && !rows?.length && <LoadingSpinner />} | ||
{(fetchState.status === ResultStatus.READY || | ||
(fetchState.status === ResultStatus.LOADING && !!rows?.length)) && | ||
(fetchState.status === ResultStatus.LOADING && !!rows?.length) || | ||
fetchState.status === ResultStatus.ERROR) && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if the first query returned an error and there are no previous query or previous rows, what does it show? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we show no result UI here if the first query we execute is invalid? @ashwin-pc There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes it should show the last valid UI state |
||
(isEnhancementsEnabled ? ( | ||
<> | ||
<MemoizedDiscoverChartContainer {...fetchState} /> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: imo this is getting really hard to understand when and where and i can imagine a regression if someone slightly changes the logic here.
i think we should consider a restructuring of this code.
to me this would be the psuedo code lemme know if im wrong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think the above psudo logics are not the same as the current logics
Rows exist or not exist only make a difference for loading status and error status;
ready status and un-initialized and no result status do not care about rows exist or not