Skip to content

Commit

Permalink
Merge branch 'master' into dn-chore/one-timestamp-format
Browse files Browse the repository at this point in the history
  • Loading branch information
daibhin committed Apr 19, 2024
2 parents 9dbe8e0 + 50df39c commit 303cd67
Show file tree
Hide file tree
Showing 99 changed files with 1,076 additions and 546 deletions.
12 changes: 6 additions & 6 deletions ee/clickhouse/models/test/test_cohort.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from posthog.models.property.util import parse_prop_grouped_clauses
from posthog.models.team import Team
from posthog.queries.util import PersonPropertiesMode
from posthog.schema import PersonsOnEventsMode
from posthog.test.base import (
BaseTest,
ClickhouseTestMixin,
Expand All @@ -25,7 +26,6 @@
snapshot_clickhouse_insert_cohortpeople_queries,
snapshot_clickhouse_queries,
)
from posthog.utils import PersonOnEventsMode


def _create_action(**kwargs):
Expand Down Expand Up @@ -145,7 +145,7 @@ def test_prop_cohort_basic_action(self):
team_id=self.team.pk,
property_group=filter.property_groups,
person_properties_mode=PersonPropertiesMode.USING_SUBQUERY
if self.team.person_on_events_mode == PersonOnEventsMode.DISABLED
if self.team.person_on_events_mode == PersonsOnEventsMode.disabled
else PersonPropertiesMode.DIRECT_ON_EVENTS,
hogql_context=filter.hogql_context,
)
Expand Down Expand Up @@ -200,7 +200,7 @@ def test_prop_cohort_basic_event_days(self):
team_id=self.team.pk,
property_group=filter.property_groups,
person_properties_mode=PersonPropertiesMode.USING_SUBQUERY
if self.team.person_on_events_mode == PersonOnEventsMode.DISABLED
if self.team.person_on_events_mode == PersonsOnEventsMode.disabled
else PersonPropertiesMode.DIRECT_ON_EVENTS,
hogql_context=filter.hogql_context,
)
Expand All @@ -225,7 +225,7 @@ def test_prop_cohort_basic_event_days(self):
team_id=self.team.pk,
property_group=filter.property_groups,
person_properties_mode=PersonPropertiesMode.USING_SUBQUERY
if self.team.person_on_events_mode == PersonOnEventsMode.DISABLED
if self.team.person_on_events_mode == PersonsOnEventsMode.disabled
else PersonPropertiesMode.DIRECT_ON_EVENTS,
hogql_context=filter.hogql_context,
)
Expand Down Expand Up @@ -276,7 +276,7 @@ def test_prop_cohort_basic_action_days(self):
team_id=self.team.pk,
property_group=filter.property_groups,
person_properties_mode=PersonPropertiesMode.USING_SUBQUERY
if self.team.person_on_events_mode == PersonOnEventsMode.DISABLED
if self.team.person_on_events_mode == PersonsOnEventsMode.disabled
else PersonPropertiesMode.DIRECT_ON_EVENTS,
hogql_context=filter.hogql_context,
)
Expand All @@ -297,7 +297,7 @@ def test_prop_cohort_basic_action_days(self):
team_id=self.team.pk,
property_group=filter.property_groups,
person_properties_mode=PersonPropertiesMode.USING_SUBQUERY
if self.team.person_on_events_mode == PersonOnEventsMode.DISABLED
if self.team.person_on_events_mode == PersonsOnEventsMode.disabled
else PersonPropertiesMode.DIRECT_ON_EVENTS,
hogql_context=filter.hogql_context,
)
Expand Down
4 changes: 2 additions & 2 deletions ee/clickhouse/queries/enterprise_cohort_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
validate_seq_date_more_recent_than_date,
)
from posthog.queries.util import PersonPropertiesMode
from posthog.utils import PersonOnEventsMode
from posthog.schema import PersonsOnEventsMode


def check_negation_clause(prop: PropertyGroup) -> Tuple[bool, bool]:
Expand Down Expand Up @@ -319,7 +319,7 @@ def _get_sequence_query(self) -> Tuple[str, Dict[str, Any], str]:

event_param_name = f"{self._cohort_pk}_event_ids"

if self.should_pushdown_persons and self._person_on_events_mode != PersonOnEventsMode.DISABLED:
if self.should_pushdown_persons and self._person_on_events_mode != PersonsOnEventsMode.disabled:
person_prop_query, person_prop_params = self._get_prop_groups(
self._inner_property_groups,
person_properties_mode=PersonPropertiesMode.DIRECT_ON_EVENTS,
Expand Down
4 changes: 2 additions & 2 deletions ee/clickhouse/queries/event_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from posthog.models.property import PropertyName
from posthog.models.team import Team
from posthog.queries.event_query.event_query import EventQuery
from posthog.utils import PersonOnEventsMode
from posthog.schema import PersonsOnEventsMode


class EnterpriseEventQuery(EventQuery):
Expand All @@ -37,7 +37,7 @@ def __init__(
extra_event_properties: List[PropertyName] = [],
extra_person_fields: List[ColumnName] = [],
override_aggregate_users_by_distinct_id: Optional[bool] = None,
person_on_events_mode: PersonOnEventsMode = PersonOnEventsMode.DISABLED,
person_on_events_mode: PersonsOnEventsMode = PersonsOnEventsMode.disabled,
**kwargs,
) -> None:
super().__init__(
Expand Down
17 changes: 9 additions & 8 deletions ee/clickhouse/queries/funnels/funnel_correlation.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
from posthog.queries.person_distinct_id_query import get_team_distinct_ids_query
from posthog.queries.person_query import PersonQuery
from posthog.queries.util import correct_result_for_sampling
from posthog.utils import PersonOnEventsMode, generate_short_id
from posthog.schema import PersonsOnEventsMode
from posthog.utils import generate_short_id


class EventDefinition(TypedDict):
Expand Down Expand Up @@ -155,7 +156,7 @@ def __init__(
def properties_to_include(self) -> List[str]:
props_to_include = []
if (
self._team.person_on_events_mode != PersonOnEventsMode.DISABLED
self._team.person_on_events_mode != PersonsOnEventsMode.disabled
and self._filter.correlation_type == FunnelCorrelationType.PROPERTIES
):
# When dealing with properties, make sure funnel response comes with properties
Expand Down Expand Up @@ -435,7 +436,7 @@ def get_properties_query(self) -> Tuple[str, Dict[str, Any]]:
return query, params

def _get_aggregation_target_join_query(self) -> str:
if self._team.person_on_events_mode == PersonOnEventsMode.PERSON_ID_NO_OVERRIDE_PROPERTIES_ON_EVENTS:
if self._team.person_on_events_mode == PersonsOnEventsMode.person_id_no_override_properties_on_events:
aggregation_person_join = f"""
JOIN funnel_actors as actors
ON event.person_id = actors.actor_id
Expand Down Expand Up @@ -502,7 +503,7 @@ def _get_events_join_query(self) -> str:

def _get_aggregation_join_query(self):
if self._filter.aggregation_group_type_index is None:
if self._team.person_on_events_mode != PersonOnEventsMode.DISABLED and groups_on_events_querying_enabled():
if self._team.person_on_events_mode != PersonsOnEventsMode.disabled and groups_on_events_querying_enabled():
return "", {}

person_query, person_query_params = PersonQuery(
Expand All @@ -522,7 +523,7 @@ def _get_aggregation_join_query(self):
return GroupsJoinQuery(self._filter, self._team.pk, join_key="funnel_actors.actor_id").get_join_query()

def _get_properties_prop_clause(self):
if self._team.person_on_events_mode != PersonOnEventsMode.DISABLED and groups_on_events_querying_enabled():
if self._team.person_on_events_mode != PersonsOnEventsMode.disabled and groups_on_events_querying_enabled():
group_properties_field = f"group{self._filter.aggregation_group_type_index}_properties"
aggregation_properties_alias = (
"person_properties" if self._filter.aggregation_group_type_index is None else group_properties_field
Expand All @@ -549,20 +550,20 @@ def _get_properties_prop_clause(self):
param_name = f"property_name_{index}"
if self._filter.aggregation_group_type_index is not None:
expression, _ = get_property_string_expr(
"groups" if self._team.person_on_events_mode == PersonOnEventsMode.DISABLED else "events",
"groups" if self._team.person_on_events_mode == PersonsOnEventsMode.disabled else "events",
property_name,
f"%({param_name})s",
aggregation_properties_alias,
materialised_table_column=aggregation_properties_alias,
)
else:
expression, _ = get_property_string_expr(
"person" if self._team.person_on_events_mode == PersonOnEventsMode.DISABLED else "events",
"person" if self._team.person_on_events_mode == PersonsOnEventsMode.disabled else "events",
property_name,
f"%({param_name})s",
aggregation_properties_alias,
materialised_table_column=aggregation_properties_alias
if self._team.person_on_events_mode != PersonOnEventsMode.DISABLED
if self._team.person_on_events_mode != PersonsOnEventsMode.disabled
else "properties",
)
person_property_params[param_name] = property_name
Expand Down
6 changes: 3 additions & 3 deletions ee/clickhouse/queries/groups_join_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from posthog.models.property.util import parse_prop_grouped_clauses
from posthog.models.team.team import groups_on_events_querying_enabled
from posthog.queries.util import PersonPropertiesMode
from posthog.utils import PersonOnEventsMode
from posthog.schema import PersonsOnEventsMode


class GroupsJoinQuery:
Expand All @@ -27,7 +27,7 @@ def __init__(
team_id: int,
column_optimizer: Optional[EnterpriseColumnOptimizer] = None,
join_key: Optional[str] = None,
person_on_events_mode: PersonOnEventsMode = PersonOnEventsMode.DISABLED,
person_on_events_mode: PersonsOnEventsMode = PersonsOnEventsMode.disabled,
) -> None:
self._filter = filter
self._team_id = team_id
Expand All @@ -38,7 +38,7 @@ def __init__(
def get_join_query(self) -> Tuple[str, Dict]:
join_queries, params = [], {}

if self._person_on_events_mode != PersonOnEventsMode.DISABLED and groups_on_events_querying_enabled():
if self._person_on_events_mode != PersonsOnEventsMode.disabled and groups_on_events_querying_enabled():
return "", {}

for group_type_index in self._column_optimizer.group_types_to_query:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from posthog.clickhouse.client import sync_execute
from posthog.models import Person
from posthog.models.filters import SessionRecordingsFilter
from posthog.schema import PersonsOnEventsMode
from posthog.session_recordings.queries.session_recording_list_from_replay_summary import (
SessionRecordingListFromReplaySummary,
)
Expand All @@ -24,7 +25,6 @@
snapshot_clickhouse_queries,
_create_event,
)
from posthog.utils import PersonOnEventsMode


@freeze_time("2021-01-01T13:46:23")
Expand Down Expand Up @@ -63,7 +63,7 @@ def create_event(
True,
False,
False,
PersonOnEventsMode.PERSON_ID_NO_OVERRIDE_PROPERTIES_ON_EVENTS,
PersonsOnEventsMode.person_id_no_override_properties_on_events,
{
"kperson_filter_pre__0": "rgInternal",
"kpersonquery_person_filter_fin__0": "rgInternal",
Expand All @@ -79,7 +79,7 @@ def create_event(
False,
False,
False,
PersonOnEventsMode.DISABLED,
PersonsOnEventsMode.disabled,
{
"kperson_filter_pre__0": "rgInternal",
"kpersonquery_person_filter_fin__0": "rgInternal",
Expand All @@ -95,7 +95,7 @@ def create_event(
False,
True,
False,
PersonOnEventsMode.PERSON_ID_OVERRIDE_PROPERTIES_ON_EVENTS,
PersonsOnEventsMode.person_id_override_properties_on_events,
{
"event_names": [],
"event_start_time": mock.ANY,
Expand All @@ -111,7 +111,7 @@ def create_event(
False,
True,
True,
PersonOnEventsMode.PERSON_ID_OVERRIDE_PROPERTIES_ON_EVENTS,
PersonsOnEventsMode.person_id_override_properties_on_events,
{
"event_end_time": mock.ANY,
"event_names": [],
Expand All @@ -130,7 +130,7 @@ def test_effect_of_poe_settings_on_query_generated(
poe_v1: bool,
poe_v2: bool,
allow_denormalized_props: bool,
expected_poe_mode: PersonOnEventsMode,
expected_poe_mode: PersonsOnEventsMode,
expected_query_params: Dict,
unmaterialized_person_column_used: bool,
materialized_event_column_used: bool,
Expand Down
4 changes: 2 additions & 2 deletions ee/tasks/subscriptions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ def _deliver_subscription_report(
raise NotImplementedError(f"{subscription.target_type} is not supported")

if not is_new_subscription_target:
subscription.set_next_delivery_date()
subscription.save()
subscription.set_next_delivery_date(subscription.next_delivery_date)
subscription.save(update_fields=["next_delivery_date"])


@shared_task(queue=CeleryQueue.SUBSCRIPTION_DELIVERY.value)
Expand Down
2 changes: 1 addition & 1 deletion ee/tasks/test/subscriptions/test_slack_subscriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


@patch("ee.tasks.subscriptions.slack_subscriptions.SlackIntegration")
@freeze_time("2022-02-02T08:55:00.000Z")
@freeze_time("2022-02-02T08:30:00.000Z")
class TestSlackSubscriptionsTasks(APIBaseTest):
subscription: Subscription
dashboard: Dashboard
Expand Down
23 changes: 12 additions & 11 deletions ee/tasks/test/subscriptions/test_subscriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,18 @@ def test_subscription_delivery_scheduling(
mock_send_email: MagicMock,
mock_send_slack: MagicMock,
) -> None:
subscriptions = [
create_subscription(team=self.team, insight=self.insight, created_by=self.user),
create_subscription(team=self.team, insight=self.insight, created_by=self.user),
create_subscription(team=self.team, dashboard=self.dashboard, created_by=self.user),
create_subscription(
team=self.team,
dashboard=self.dashboard,
created_by=self.user,
deleted=True,
),
]
with freeze_time("2022-02-02T08:30:00.000Z"): # Create outside of buffer before running
subscriptions = [
create_subscription(team=self.team, insight=self.insight, created_by=self.user),
create_subscription(team=self.team, insight=self.insight, created_by=self.user),
create_subscription(team=self.team, dashboard=self.dashboard, created_by=self.user),
create_subscription(
team=self.team,
dashboard=self.dashboard,
created_by=self.user,
deleted=True,
),
]
# Modify a subscription to have its target time at least an hour ahead
subscriptions[2].start_date = datetime(2022, 1, 1, 10, 0).replace(tzinfo=ZoneInfo("UTC"))
subscriptions[2].save()
Expand Down
Binary file modified frontend/__snapshots__/lemon-ui-icons--shelf-p--dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/__snapshots__/lemon-ui-icons--shelf-p--light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/__snapshots__/lemon-ui-icons--shelf-s--dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/__snapshots__/lemon-ui-icons--shelf-s--light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion frontend/src/lib/lemon-ui/LemonTabs/LemonTabs.scss
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
.LemonTabs {
--lemon-tabs-margin-bottom: 1rem;
--lemon-tabs-gap: 2rem;
--lemon-tabs-margin-bottom: 1rem;
--lemon-tabs-content-padding: 0.75rem 0;

position: relative;
display: flex;
flex-direction: column;
align-self: stretch;

&--small {
--lemon-tabs-gap: 1rem;
--lemon-tabs-margin-bottom: 0.5rem;
--lemon-tabs-content-padding: 0.375rem 0;
}

.Navigation3000__scene > &:first-child,
.Navigation3000__scene > :first-child > &:first-child {
margin-top: -0.75rem;
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/lib/lemon-ui/LemonTabs/LemonTabs.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,8 @@ const Template: StoryFn<typeof LemonTabsComponent> = (props) => {
return <LemonTabsComponent {...props} activeKey={activeKey} onChange={(newValue) => setActiveKey(newValue)} />
}

export const LemonTabs: Story = Template.bind({})
LemonTabs.args = {}
export const Default: Story = Template.bind({})
Default.args = {}

export const Small: Story = Template.bind({})
Small.args = { size: 'small' }
4 changes: 3 additions & 1 deletion frontend/src/lib/lemon-ui/LemonTabs/LemonTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface LemonTabsProps<T extends string | number> {
onChange?: (key: T) => void
/** List of tabs. Falsy entries are ignored - they're there to make conditional tabs convenient. */
tabs: (LemonTab<T> | null | false)[]
size?: 'small' | 'medium'
'data-attr'?: string
}

Expand All @@ -40,6 +41,7 @@ export function LemonTabs<T extends string | number>({
activeKey,
onChange,
tabs,
size = 'medium',
'data-attr': dataAttr,
}: LemonTabsProps<T>): JSX.Element {
const { containerRef, selectionRef, sliderWidth, sliderOffset, transitioning } = useSliderPositioning<
Expand All @@ -53,7 +55,7 @@ export function LemonTabs<T extends string | number>({

return (
<div
className={clsx('LemonTabs', transitioning && 'LemonTabs--transitioning')}
className={clsx('LemonTabs', transitioning && 'LemonTabs--transitioning', `LemonTabs--${size}`)}
// eslint-disable-next-line react/forbid-dom-props
style={
{
Expand Down
Loading

0 comments on commit 303cd67

Please sign in to comment.