From cb04d8831ad5e6616532ce88ebb58fd5ec79da1e Mon Sep 17 00:00:00 2001 From: Robbie Coomber Date: Fri, 22 Nov 2024 16:56:35 +0000 Subject: [PATCH] Add minor tweaks --- ee/hogai/taxonomy_agent/toolkit.py | 4 ++-- .../VerticalNestedDND/VerticalNestedDND.tsx | 2 -- .../lemon-ui/VerticalNestedDND/styles.scss | 21 ------------------ .../environment/CustomChannelTypes.tsx | 4 +++- posthog/hogql/database/schema/channel_type.py | 22 ++----------------- posthog/hogql/database/schema/sessions_v1.py | 7 +++--- posthog/hogql/database/schema/sessions_v2.py | 7 +++--- 7 files changed, 13 insertions(+), 54 deletions(-) delete mode 100644 frontend/src/lib/lemon-ui/VerticalNestedDND/styles.scss diff --git a/ee/hogai/taxonomy_agent/toolkit.py b/ee/hogai/taxonomy_agent/toolkit.py index f6d44af88a9..2af39253b9e 100644 --- a/ee/hogai/taxonomy_agent/toolkit.py +++ b/ee/hogai/taxonomy_agent/toolkit.py @@ -8,7 +8,7 @@ from typing import Literal, Optional, TypedDict, Union, cast from pydantic import BaseModel, Field, RootModel from ee.hogai.taxonomy import CORE_FILTER_DEFINITIONS_BY_GROUP -from posthog.hogql.database.schema.channel_type import POSSIBLE_CHANNEL_TYPES +from posthog.hogql.database.schema.channel_type import DEFAULT_CHANNEL_TYPES from posthog.hogql_queries.ai.actors_property_taxonomy_query_runner import ActorsPropertyTaxonomyQueryRunner from posthog.hogql_queries.ai.event_taxonomy_query_runner import EventTaxonomyQueryRunner from posthog.hogql_queries.query_runner import ExecutionMode @@ -353,7 +353,7 @@ class TaxonomyAgentToolkit(ABC): sample_values: list[str | int | float] if property_name == "$channel_type": - sample_values = cast(list[str | int | float], POSSIBLE_CHANNEL_TYPES.copy()) + sample_values = cast(list[str | int | float], DEFAULT_CHANNEL_TYPES.copy()) sample_count = len(sample_values) is_str = True elif ( diff --git a/frontend/src/lib/lemon-ui/VerticalNestedDND/VerticalNestedDND.tsx b/frontend/src/lib/lemon-ui/VerticalNestedDND/VerticalNestedDND.tsx index 6bdbb97107d..69b4992ec16 100644 --- a/frontend/src/lib/lemon-ui/VerticalNestedDND/VerticalNestedDND.tsx +++ b/frontend/src/lib/lemon-ui/VerticalNestedDND/VerticalNestedDND.tsx @@ -1,5 +1,3 @@ -import './styles.scss' - import { closestCenter, CollisionDetection, diff --git a/frontend/src/lib/lemon-ui/VerticalNestedDND/styles.scss b/frontend/src/lib/lemon-ui/VerticalNestedDND/styles.scss deleted file mode 100644 index 9e498671d32..00000000000 --- a/frontend/src/lib/lemon-ui/VerticalNestedDND/styles.scss +++ /dev/null @@ -1,21 +0,0 @@ -.VerticalNestedDNDContainer { - box-sizing: initial; - display: flex; - flex: 1; - flex-direction: column; - overflow: hidden; - background: var(--bg-light); - border: 1px solid var(--border); - border-radius: var(--radius); -} - -.VerticalNestedDNDItem { - box-sizing: initial; - display: flex; - flex: 1; - flex-direction: column; - overflow: hidden; - background: var(--bg-light); - border: 1px solid var(--border); - border-radius: var(--radius); -} diff --git a/frontend/src/scenes/settings/environment/CustomChannelTypes.tsx b/frontend/src/scenes/settings/environment/CustomChannelTypes.tsx index e398e921a58..10dc8f6c139 100644 --- a/frontend/src/scenes/settings/environment/CustomChannelTypes.tsx +++ b/frontend/src/scenes/settings/environment/CustomChannelTypes.tsx @@ -138,7 +138,9 @@ export function CustomChannelTypes(): JSX.Element { Object.values(DefaultChannelTypes).forEach((channelType) => { optionsSet.add(channelType) }) - return Array.from(optionsSet).map((channelType) => ({ label: channelType, key: channelType })) + return Array.from(optionsSet) + .filter(Boolean) + .map((channelType) => ({ label: channelType, key: channelType })) }, [customChannelTypeRules]) return ( diff --git a/posthog/hogql/database/schema/channel_type.py b/posthog/hogql/database/schema/channel_type.py index e0807f6a5e1..ff664f24152 100644 --- a/posthog/hogql/database/schema/channel_type.py +++ b/posthog/hogql/database/schema/channel_type.py @@ -8,6 +8,7 @@ from posthog.schema import ( CustomChannelRule, CustomChannelOperator, CustomChannelField, + DefaultChannelTypes, ) @@ -288,23 +289,4 @@ multiIf( return builtin_rules -POSSIBLE_CHANNEL_TYPES = [ - "Cross Network", - "Paid Search", - "Paid Social", - "Paid Video", - "Paid Shopping", - "Paid Unknown", - "Direct", - "Organic Search", - "Organic Social", - "Organic Video", - "Organic Shopping", - "Push", - "SMS", - "Audio", - "Email", - "Referral", - "Affiliate", - "Unknown", -] +DEFAULT_CHANNEL_TYPES = [entry.value for entry in DefaultChannelTypes] diff --git a/posthog/hogql/database/schema/sessions_v1.py b/posthog/hogql/database/schema/sessions_v1.py index 178aaec31ab..91b51faf6eb 100644 --- a/posthog/hogql/database/schema/sessions_v1.py +++ b/posthog/hogql/database/schema/sessions_v1.py @@ -20,6 +20,7 @@ from posthog.hogql.database.models import ( from posthog.hogql.database.schema.channel_type import ( create_channel_type_expr, ChannelTypeExprs, + DEFAULT_CHANNEL_TYPES, ) from posthog.hogql.database.schema.util.where_clause_extractor import SessionMinTimestampWhereClauseExtractorV1 from posthog.hogql.errors import ResolutionError @@ -29,7 +30,7 @@ from posthog.models.sessions.sql import ( SELECT_SESSION_PROP_STRING_VALUES_SQL, ) from posthog.queries.insight import insight_sync_execute -from posthog.schema import BounceRatePageViewMode, DefaultChannelTypes +from posthog.schema import BounceRatePageViewMode if TYPE_CHECKING: from posthog.models.team import Team @@ -410,9 +411,7 @@ def get_lazy_session_table_values_v1(key: str, search_term: Optional[str], team: if key == "$channel_type": return [ - [entry.value] - for entry in DefaultChannelTypes - if not search_term or search_term.lower() in entry.value.lower() + [entry] for entry in DEFAULT_CHANNEL_TYPES if not search_term or search_term.lower() in entry.value.lower() ] field_definition = LAZY_SESSIONS_FIELDS.get(key) diff --git a/posthog/hogql/database/schema/sessions_v2.py b/posthog/hogql/database/schema/sessions_v2.py index e36e46bc333..407dd9a7574 100644 --- a/posthog/hogql/database/schema/sessions_v2.py +++ b/posthog/hogql/database/schema/sessions_v2.py @@ -20,6 +20,7 @@ from posthog.hogql.database.models import ( from posthog.hogql.database.schema.channel_type import ( create_channel_type_expr, ChannelTypeExprs, + DEFAULT_CHANNEL_TYPES, ) from posthog.hogql.database.schema.sessions_v1 import null_if_empty from posthog.hogql.database.schema.util.where_clause_extractor import SessionMinTimestampWhereClauseExtractorV2 @@ -31,7 +32,7 @@ from posthog.models.raw_sessions.sql import ( RAW_SELECT_SESSION_PROP_STRING_VALUES_SQL_WITH_FILTER, ) from posthog.queries.insight import insight_sync_execute -from posthog.schema import BounceRatePageViewMode, CustomChannelRule, DefaultChannelTypes +from posthog.schema import BounceRatePageViewMode, CustomChannelRule if TYPE_CHECKING: from posthog.models.team import Team @@ -502,9 +503,7 @@ def get_lazy_session_table_values_v2(key: str, search_term: Optional[str], team: else: custom_channel_types = [] default_channel_types = [ - entry.value - for entry in DefaultChannelTypes - if not search_term or search_term.lower() in entry.value.lower() + entry for entry in DEFAULT_CHANNEL_TYPES if not search_term or search_term.lower() in entry.value.lower() ] # merge the list, keep the order, and remove duplicates return [[name] for name in list(dict.fromkeys(custom_channel_types + default_channel_types))]