From 7989ca93722a492cbf4034d5da1aa615facaeb2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Obermu=CC=88ller?= Date: Wed, 17 Jan 2024 00:18:44 +0100 Subject: [PATCH] fixes --- .../InsightQuery/utils/queryNodeToFilter.ts | 69 +++++++++++++++---- 1 file changed, 55 insertions(+), 14 deletions(-) diff --git a/frontend/src/queries/nodes/InsightQuery/utils/queryNodeToFilter.ts b/frontend/src/queries/nodes/InsightQuery/utils/queryNodeToFilter.ts index 587b0c81085bc1..3b0bf6b17ce235 100644 --- a/frontend/src/queries/nodes/InsightQuery/utils/queryNodeToFilter.ts +++ b/frontend/src/queries/nodes/InsightQuery/utils/queryNodeToFilter.ts @@ -1,5 +1,11 @@ import { objectClean } from 'lib/utils' -import { isFunnelsFilter, isLifecycleFilter, isStickinessFilter, isTrendsFilter } from 'scenes/insights/sharedUtils' +import { + isFunnelsFilter, + isLifecycleFilter, + isPathsFilter, + isStickinessFilter, + isTrendsFilter, +} from 'scenes/insights/sharedUtils' import { ActionsNode, @@ -7,7 +13,10 @@ import { EventsNode, InsightNodeKind, InsightQueryNode, + LifecycleFilterLegacy, NodeKind, + PathsFilterLegacy, + StickinessFilterLegacy, TrendsFilterLegacy, } from '~/queries/schema' import { @@ -148,17 +157,18 @@ export const queryNodeToFilter = (query: InsightQueryNode): Partial // get node specific filter properties e.g. trendsFilter, funnelsFilter, ... const insightFilter = JSON.parse(JSON.stringify(query[filterMap[query.kind]] || {})) - const legacyProps: TrendsFilterLegacy = {} + const legacyProps = {} if (isTrendsQuery(query)) { - legacyProps.smoothing_intervals = insightFilter.smoothingIntervals - legacyProps.decimal_places = insightFilter.decimalPlaces - legacyProps.aggregation_axis_format = insightFilter.aggregationAxisFormat - legacyProps.aggregation_axis_postfix = insightFilter.aggregationAxisPostfix - legacyProps.aggregation_axis_prefix = insightFilter.aggregationAxisPrefix - legacyProps.show_labels_on_series = insightFilter.showLabelsOnSeries - legacyProps.show_percent_stack_view = insightFilter.showPercentStackView - legacyProps.show_legend = insightFilter.showLegend - legacyProps.show_values_on_series = insightFilter.showValuesOnSeries + ;(legacyProps as TrendsFilterLegacy).smoothing_intervals = + insightFilter.smoothingIntervals(legacyProps as TrendsFilterLegacy).decimal_places = + insightFilter.decimalPlaces(legacyProps as TrendsFilterLegacy).aggregation_axis_format = + insightFilter.aggregationAxisFormat(legacyProps as TrendsFilterLegacy).aggregation_axis_postfix = + insightFilter.aggregationAxisPostfix(legacyProps as TrendsFilterLegacy).aggregation_axis_prefix = + insightFilter.aggregationAxisPrefix(legacyProps as TrendsFilterLegacy).show_labels_on_series = + insightFilter.showLabelsOnSeries(legacyProps as TrendsFilterLegacy).show_percent_stack_view = + insightFilter.showPercentStackView(legacyProps as TrendsFilterLegacy).show_legend = + insightFilter.showLegend(legacyProps as TrendsFilterLegacy).show_values_on_series = + insightFilter.showValuesOnSeries delete insightFilter.smoothingIntervals delete insightFilter.decimalPlaces delete insightFilter.aggregationAxisFormat @@ -169,13 +179,44 @@ export const queryNodeToFilter = (query: InsightQueryNode): Partial delete insightFilter.showLegend delete insightFilter.showValuesOnSeries } else if (isStickinessFilter(query)) { - legacyProps.show_legend = insightFilter.showLegend - legacyProps.show_values_on_series = insightFilter.showValuesOnSeries + ;(legacyProps as StickinessFilterLegacy).show_legend = insightFilter.showLegend( + legacyProps as StickinessFilterLegacy + ).show_values_on_series = insightFilter.showValuesOnSeries delete insightFilter.showLegend delete insightFilter.showValuesOnSeries } else if (isLifecycleFilter(query)) { - legacyProps.show_values_on_series = insightFilter.showValuesOnSeries + ;(legacyProps as LifecycleFilterLegacy).show_values_on_series = insightFilter.showValuesOnSeries delete insightFilter.showValuesOnSeries + } else if (isPathsFilter(query)) { + ;(legacyProps as PathsFilterLegacy).edge_limit = + insightFilter.edgeLimit(legacyProps as PathsFilterLegacy).paths_hogql_expression = + insightFilter.pathsHogQLExpression(legacyProps as PathsFilterLegacy).include_event_types = + insightFilter.includeEventTypes(legacyProps as PathsFilterLegacy).start_point = + insightFilter.startPoint(legacyProps as PathsFilterLegacy).end_point = + insightFilter.endPoint(legacyProps as PathsFilterLegacy).path_groupings = + insightFilter.pathGroupings(legacyProps as PathsFilterLegacy).exclude_events = + insightFilter.excludeEvents(legacyProps as PathsFilterLegacy).step_limit = + insightFilter.stepLimit(legacyProps as PathsFilterLegacy).path_replacements = + insightFilter.pathReplacements(legacyProps as PathsFilterLegacy).local_path_cleaning_filters = + insightFilter.localPathCleaningFilters(legacyProps as PathsFilterLegacy).min_edge_weight = + insightFilter.minEdgeWeight(legacyProps as PathsFilterLegacy).max_edge_weight = + insightFilter.maxEdgeWeight(legacyProps as PathsFilterLegacy).funnel_paths = + insightFilter.funnelPaths(legacyProps as PathsFilterLegacy).funnel_filter = + insightFilter.funnelFilter + delete insightFilter.edgeLimit + delete insightFilter.pathsHogQLExpression + delete insightFilter.includeEventTypes + delete insightFilter.startPoint + delete insightFilter.endPoint + delete insightFilter.pathGroupings + delete insightFilter.excludeEvents + delete insightFilter.stepLimit + delete insightFilter.pathReplacements + delete insightFilter.localPathCleaningFilters + delete insightFilter.minEdgeWeight + delete insightFilter.maxEdgeWeight + delete insightFilter.funnelPaths + delete insightFilter.funnelFilter } Object.assign(filters, insightFilter) Object.assign(filters, legacyProps)