From 632cae6df296701982a1acf0cdda9e5c8016f791 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Obermu=CC=88ller?= Date: Mon, 18 Sep 2023 20:49:32 +0200 Subject: [PATCH] avoid numeric insights api for queries with hogql support --- frontend/src/queries/nodes/DataNode/dataNodeLogic.ts | 11 +++++++++-- frontend/src/queries/query.ts | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/frontend/src/queries/nodes/DataNode/dataNodeLogic.ts b/frontend/src/queries/nodes/DataNode/dataNodeLogic.ts index df6c3061a38170..bcb30766fe827d 100644 --- a/frontend/src/queries/nodes/DataNode/dataNodeLogic.ts +++ b/frontend/src/queries/nodes/DataNode/dataNodeLogic.ts @@ -17,7 +17,7 @@ import { loaders } from 'kea-loaders' import type { dataNodeLogicType } from './dataNodeLogicType' import { AnyResponseType, DataNode, EventsQuery, EventsQueryResponse, PersonsNode, QueryTiming } from '~/queries/schema' import { query } from '~/queries/query' -import { isInsightQueryNode, isEventsQuery, isPersonsNode } from '~/queries/utils' +import { isInsightQueryNode, isEventsQuery, isPersonsNode, isQueryWithHogQLSupport } from '~/queries/utils' import { subscriptions } from 'kea-subscriptions' import { objectsEqual, shouldCancelQuery, uuid } from 'lib/utils' import clsx from 'clsx' @@ -29,6 +29,8 @@ import { teamLogic } from 'scenes/teamLogic' import equal from 'fast-deep-equal' import { filtersToQueryNode } from '../InsightQuery/utils/filtersToQueryNode' import { compareInsightQuery } from 'scenes/insights/utils/compareInsightQuery' +import { featureFlagLogic } from 'lib/logic/featureFlagLogic' +import { FEATURE_FLAGS } from 'lib/constants' export interface DataNodeLogicProps { key: string @@ -52,7 +54,7 @@ const queryEqual = (a: DataNode, b: DataNode): boolean => { export const dataNodeLogic = kea([ path(['queries', 'nodes', 'dataNodeLogic']), connect({ - values: [userLogic, ['user'], teamLogic, ['currentTeamId']], + values: [userLogic, ['user'], teamLogic, ['currentTeamId'], featureFlagLogic, ['featureFlags']], }), props({ query: {} } as DataNodeLogicProps), key((props) => props.key), @@ -96,6 +98,7 @@ export const dataNodeLogic = kea([ } if ( isInsightQueryNode(props.query) && + !(values.hogQLInsightsFlagEnabled && isQueryWithHogQLSupport(props.query)) && props.cachedResults && props.cachedResults['id'] && props.cachedResults['filters'] && @@ -309,6 +312,10 @@ export const dataNodeLogic = kea([ () => [(_, props) => props.cachedResults ?? null], (cachedResults: AnyResponseType | null): boolean => !!cachedResults, ], + hogQLInsightsFlagEnabled: [ + (s) => [s.featureFlags], + (featureFlags) => featureFlags[FEATURE_FLAGS.HOGQL_INSIGHTS], + ], query: [(_, p) => [p.query], (query) => query], newQuery: [ (s, p) => [p.query, s.response], diff --git a/frontend/src/queries/query.ts b/frontend/src/queries/query.ts index 8551aa83e564b7..bd2e67b573186b 100644 --- a/frontend/src/queries/query.ts +++ b/frontend/src/queries/query.ts @@ -10,7 +10,7 @@ import { isTimeToSeeDataSessionsNode, isHogQLQuery, isInsightVizNode, - isLifecycleQuery, + isQueryWithHogQLSupport, } from './utils' import api, { ApiMethodOptions } from 'lib/api' import { getCurrentTeamId } from 'lib/utils/logics' @@ -114,7 +114,7 @@ export async function query( try { if (isPersonsNode(queryNode)) { response = await api.get(getPersonsEndpoint(queryNode), methodOptions) - } else if (isInsightQueryNode(queryNode) && !(hogQLInsightsFlagEnabled && isLifecycleQuery(queryNode))) { + } else if (isInsightQueryNode(queryNode) && !(hogQLInsightsFlagEnabled && isQueryWithHogQLSupport(queryNode))) { const filters = queryNodeToFilter(queryNode) const params = { ...filters,