From 865c1c38701d8acaa51cf4e83031839aabe62cd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Obermu=CC=88ller?= Date: Wed, 31 May 2023 21:46:32 +0200 Subject: [PATCH] refactor(data-exploration): remove dead code from summarizeInsight function --- .../Cards/InsightCard/InsightCard.tsx | 1 - .../src/scenes/insights/InsightPageHeader.tsx | 1 - frontend/src/scenes/insights/insightLogic.ts | 19 ++----------------- .../scenes/insights/summarizeInsight.test.ts | 2 -- .../src/scenes/insights/summarizeInsight.ts | 4 +--- .../scenes/saved-insights/SavedInsights.tsx | 2 -- 6 files changed, 3 insertions(+), 26 deletions(-) diff --git a/frontend/src/lib/components/Cards/InsightCard/InsightCard.tsx b/frontend/src/lib/components/Cards/InsightCard/InsightCard.tsx index e4b091861d0a5..70ee897d088fa 100644 --- a/frontend/src/lib/components/Cards/InsightCard/InsightCard.tsx +++ b/frontend/src/lib/components/Cards/InsightCard/InsightCard.tsx @@ -237,7 +237,6 @@ function InsightMeta({ aggregationLabel, cohortsById, mathDefinitions, - isUsingDataExploration: true, isUsingDashboardQueries: !!featureFlags[FEATURE_FLAGS.HOGQL], }) diff --git a/frontend/src/scenes/insights/InsightPageHeader.tsx b/frontend/src/scenes/insights/InsightPageHeader.tsx index 30181810aace8..ffc2d3a60909c 100644 --- a/frontend/src/scenes/insights/InsightPageHeader.tsx +++ b/frontend/src/scenes/insights/InsightPageHeader.tsx @@ -119,7 +119,6 @@ export function InsightPageHeader({ insightLogicProps }: { insightLogicProps: In name="name" value={insight.name || ''} placeholder={summarizeInsight(query, filters, { - isUsingDataExploration, aggregationLabel, cohortsById, mathDefinitions, diff --git a/frontend/src/scenes/insights/insightLogic.ts b/frontend/src/scenes/insights/insightLogic.ts index 23d1b592176b9..87395487a18c9 100644 --- a/frontend/src/scenes/insights/insightLogic.ts +++ b/frontend/src/scenes/insights/insightLogic.ts @@ -607,24 +607,9 @@ export const insightLogic = kea([ !!props.dashboardItemId && props.dashboardItemId !== 'new' && !props.dashboardItemId.startsWith('new-'), ], derivedName: [ - (s) => [ - s.insight, - s.aggregationLabel, - s.cohortsById, - s.mathDefinitions, - s.isUsingDataExploration, - s.isUsingDashboardQueries, - ], - ( - insight, - aggregationLabel, - cohortsById, - mathDefinitions, - isUsingDataExploration, - isUsingDashboardQueries - ) => + (s) => [s.insight, s.aggregationLabel, s.cohortsById, s.mathDefinitions, s.isUsingDashboardQueries], + (insight, aggregationLabel, cohortsById, mathDefinitions, isUsingDashboardQueries) => summarizeInsight(insight.query, insight.filters || {}, { - isUsingDataExploration, aggregationLabel, cohortsById, mathDefinitions, diff --git a/frontend/src/scenes/insights/summarizeInsight.test.ts b/frontend/src/scenes/insights/summarizeInsight.test.ts index eb110c3804006..dc7c1dd0c59bf 100644 --- a/frontend/src/scenes/insights/summarizeInsight.test.ts +++ b/frontend/src/scenes/insights/summarizeInsight.test.ts @@ -69,13 +69,11 @@ const summaryContext: SummaryContext = { aggregationLabel, cohortsById: cohortIdsMapped, mathDefinitions, - isUsingDataExploration: false, isUsingDashboardQueries: false, } const flagsOnSummaryContext: SummaryContext = { ...summaryContext, - isUsingDataExploration: true, isUsingDashboardQueries: true, } diff --git a/frontend/src/scenes/insights/summarizeInsight.ts b/frontend/src/scenes/insights/summarizeInsight.ts index fba6014b00385..da74a706b9eb5 100644 --- a/frontend/src/scenes/insights/summarizeInsight.ts +++ b/frontend/src/scenes/insights/summarizeInsight.ts @@ -329,7 +329,6 @@ function summariseQuery(query: Node): string { } export interface SummaryContext { - isUsingDataExploration: boolean isUsingDashboardQueries: boolean aggregationLabel: groupsModelType['values']['aggregationLabel'] cohortsById: cohortsModelType['values']['cohortsById'] @@ -342,8 +341,7 @@ export function summarizeInsight( context: SummaryContext ): string { const hasFilters = Object.keys(filters || {}).length > 0 - - return context.isUsingDataExploration && isInsightVizNode(query) + return isInsightVizNode(query) ? summarizeInsightQuery(query.source, context) : context.isUsingDashboardQueries && !!query && !isInsightVizNode(query) ? summariseQuery(query) diff --git a/frontend/src/scenes/saved-insights/SavedInsights.tsx b/frontend/src/scenes/saved-insights/SavedInsights.tsx index f2432bdb21da4..437f600c1e210 100644 --- a/frontend/src/scenes/saved-insights/SavedInsights.tsx +++ b/frontend/src/scenes/saved-insights/SavedInsights.tsx @@ -334,7 +334,6 @@ function SavedInsightsGrid(): JSX.Element { export function SavedInsights(): JSX.Element { const { featureFlags } = useValues(featureFlagLogic) - const isUsingDataExploration = true const isUsingDashboardQueries = !!featureFlags[FEATURE_FLAGS.HOGQL] const { loadInsights, updateFavoritedInsight, renameInsight, duplicateInsight, setSavedInsightsFilters } = @@ -372,7 +371,6 @@ export function SavedInsights(): JSX.Element { {name || ( {summarizeInsight(insight.query, insight.filters, { - isUsingDataExploration, aggregationLabel, cohortsById, mathDefinitions,