Skip to content

Commit

Permalink
feat: use cached insight result in SavedInsight (#17510)
Browse files Browse the repository at this point in the history
  • Loading branch information
daibhin authored Sep 19, 2023
1 parent 737f482 commit ec67915
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions frontend/src/queries/nodes/SavedInsight/SavedInsight.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@ import { useValues } from 'kea'
import { insightLogic } from 'scenes/insights/insightLogic'
import { Query } from '~/queries/Query/Query'
import { SavedInsightNode, QueryContext } from '~/queries/schema'
import { InsightLogicProps, InsightModel } from '~/types'
import { InsightLogicProps } from '~/types'
import { Animation } from 'lib/components/Animation/Animation'
import { AnimationType } from 'lib/animations/animations'
import { insightDataLogic } from 'scenes/insights/insightDataLogic'

interface InsightProps {
query: SavedInsightNode
cachedResults?: Partial<InsightModel> | null
context?: QueryContext
}

export function SavedInsight({ query: propsQuery, context, cachedResults }: InsightProps): JSX.Element {
const insightProps: InsightLogicProps = { dashboardItemId: propsQuery.shortId, cachedInsight: cachedResults }
export function SavedInsight({ query: propsQuery, context }: InsightProps): JSX.Element {
const insightProps: InsightLogicProps = { dashboardItemId: propsQuery.shortId }
const { insight, insightLoading } = useValues(insightLogic(insightProps))
const { query: dataQuery } = useValues(insightDataLogic(insightProps))

Expand All @@ -33,5 +32,5 @@ export function SavedInsight({ query: propsQuery, context, cachedResults }: Insi

const query = { ...propsQuery, ...dataQuery, full: propsQuery.full }

return <Query query={query} context={{ ...context, insightProps }} />
return <Query query={query} cachedResults={insight.result} context={{ ...context, insightProps }} />
}

0 comments on commit ec67915

Please sign in to comment.