Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
thmsobrmlr committed Jan 16, 2024
1 parent a370ede commit 7989ca9
Showing 1 changed file with 55 additions and 14 deletions.
69 changes: 55 additions & 14 deletions frontend/src/queries/nodes/InsightQuery/utils/queryNodeToFilter.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
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,
BreakdownFilter,
EventsNode,
InsightNodeKind,
InsightQueryNode,
LifecycleFilterLegacy,
NodeKind,
PathsFilterLegacy,
StickinessFilterLegacy,
TrendsFilterLegacy,
} from '~/queries/schema'
import {
Expand Down Expand Up @@ -148,17 +157,18 @@ export const queryNodeToFilter = (query: InsightQueryNode): Partial<FilterType>

// 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
Expand All @@ -169,13 +179,44 @@ export const queryNodeToFilter = (query: InsightQueryNode): Partial<FilterType>
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)
Expand Down

0 comments on commit 7989ca9

Please sign in to comment.