Skip to content

Commit

Permalink
refactor(data-exploration): remove dead code from summarizeInsight fu…
Browse files Browse the repository at this point in the history
…nction (#15824)
  • Loading branch information
thmsobrmlr authored Jun 1, 2023
1 parent b5b2665 commit 66f7b7e
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ function InsightMeta({
aggregationLabel,
cohortsById,
mathDefinitions,
isUsingDataExploration: true,
isUsingDashboardQueries: !!featureFlags[FEATURE_FLAGS.HOGQL],
})

Expand Down
1 change: 0 additions & 1 deletion frontend/src/scenes/insights/InsightPageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ export function InsightPageHeader({ insightLogicProps }: { insightLogicProps: In
name="name"
value={insight.name || ''}
placeholder={summarizeInsight(query, filters, {
isUsingDataExploration,
aggregationLabel,
cohortsById,
mathDefinitions,
Expand Down
19 changes: 2 additions & 17 deletions frontend/src/scenes/insights/insightLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -606,24 +606,9 @@ export const insightLogic = kea<insightLogicType>([
!!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,
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/scenes/insights/summarizeInsight.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,11 @@ const summaryContext: SummaryContext = {
aggregationLabel,
cohortsById: cohortIdsMapped,
mathDefinitions,
isUsingDataExploration: false,
isUsingDashboardQueries: false,
}

const flagsOnSummaryContext: SummaryContext = {
...summaryContext,
isUsingDataExploration: true,
isUsingDashboardQueries: true,
}

Expand Down
4 changes: 1 addition & 3 deletions frontend/src/scenes/insights/summarizeInsight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,6 @@ function summariseQuery(query: Node): string {
}

export interface SummaryContext {
isUsingDataExploration: boolean
isUsingDashboardQueries: boolean
aggregationLabel: groupsModelType['values']['aggregationLabel']
cohortsById: cohortsModelType['values']['cohortsById']
Expand All @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/scenes/saved-insights/SavedInsights.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 } =
Expand Down Expand Up @@ -372,7 +371,6 @@ export function SavedInsights(): JSX.Element {
{name || (
<i>
{summarizeInsight(insight.query, insight.filters, {
isUsingDataExploration,
aggregationLabel,
cohortsById,
mathDefinitions,
Expand Down

0 comments on commit 66f7b7e

Please sign in to comment.