Skip to content

Commit

Permalink
revert(insights): Make initial single insight load async (#23977)
Browse files Browse the repository at this point in the history
  • Loading branch information
Twixes authored Jul 25, 2024
1 parent dfaa8c8 commit caa98ae
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 355 deletions.
6 changes: 2 additions & 4 deletions frontend/src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -895,16 +895,14 @@ const api = {
insights: {
loadInsight(
shortId: InsightModel['short_id'],
basic?: boolean,
refresh?: RefreshType
basic?: boolean
): Promise<PaginatedResponse<Partial<InsightModel>>> {
return new ApiRequest()
.insights()
.withQueryString(
toParams({
short_id: encodeURIComponent(shortId),
basic,
refresh,
basic: basic,
})
)
.get()
Expand Down
11 changes: 3 additions & 8 deletions frontend/src/queries/nodes/DataNode/dataNodeLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,7 @@ export const dataNodeLogic = kea<dataNodeLogicType>([
if (oldProps.query?.kind && props.query.kind !== oldProps.query.kind) {
actions.clearResponse()
}
const queryStatus = (props.cachedResults?.query_status || null) as QueryStatus | null
if (queryStatus?.complete === false) {
// If there is an incomplete query, load the data with the same query_id which should return its status
actions.loadData(undefined, queryStatus.id)
} else if (
if (
!(props.cachedResults && props.key.includes('dashboard')) && // Don't load data on dashboard if cached results are available
!queryEqual(props.query, oldProps.query) &&
(!props.cachedResults ||
Expand All @@ -145,7 +141,7 @@ export const dataNodeLogic = kea<dataNodeLogicType>([
}
}),
actions({
loadData: (refresh = false, queryId?: string) => ({ refresh, queryId: queryId || uuid() }),
loadData: (refresh = false) => ({ refresh, queryId: uuid() }),
abortAnyRunningQuery: true,
abortQuery: (payload: { queryId: string }) => payload,
cancelQuery: true,
Expand All @@ -170,8 +166,7 @@ export const dataNodeLogic = kea<dataNodeLogicType>([
return props.cachedResults
}

const queryStatus = (props.cachedResults?.query_status || null) as QueryStatus | null
if (props.cachedResults && !refresh && queryStatus?.complete !== false) {
if (props.cachedResults && !refresh) {
if (props.cachedResults['result'] || props.cachedResults['results']) {
return props.cachedResults
}
Expand Down
Loading

0 comments on commit caa98ae

Please sign in to comment.