Skip to content
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

refactor(data-exploration): remove dead code from summarizeInsight function #15824

Merged
merged 2 commits into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -119,7 +119,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 @@ -607,24 +607,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