0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-12-01 04:12:23 +01:00

Always include prop filters in get_entity_filtering_params

This commit is contained in:
Michael Matloka 2021-08-10 00:30:54 +02:00
parent 6b69a09759
commit 4f61edd19a
2 changed files with 4 additions and 11 deletions

View File

@ -6,9 +6,7 @@ from posthog.constants import TREND_FILTER_TYPE_ACTIONS
from posthog.models.entity import Entity
def get_entity_filtering_params(
entity: Entity, team_id: int, table_name: str = "", *, with_prop_filters: bool = False
) -> Tuple[Dict, Dict]:
def get_entity_filtering_params(entity: Entity, team_id: int, table_name: str = "") -> Tuple[Dict, Dict]:
params: Dict[str, Any]
content_sql_params: Dict[str, str]
if entity.type == TREND_FILTER_TYPE_ACTIONS:
@ -16,12 +14,7 @@ def get_entity_filtering_params(
action_query, params = format_action_filter(action, table_name=table_name)
content_sql_params = {"entity_query": "AND {action_query}".format(action_query=action_query)}
else:
prop_filters = ""
if with_prop_filters:
prop_filters, params = parse_prop_clauses(entity.properties, team_id)
else:
prop_filters, params = "", {}
prop_filters, params = parse_prop_clauses(entity.properties, team_id)
params["event"] = entity.id
content_sql_params = {"entity_query": f"AND event = %(event)s {prop_filters}"}
return params, content_sql_params

View File

@ -47,7 +47,7 @@ def get_breakdown_person_prop_values(
prepend="person",
)
entity_params, entity_format_params = get_entity_filtering_params(entity, team_id, with_prop_filters=True)
entity_params, entity_format_params = get_entity_filtering_params(entity, team_id)
elements_query = TOP_PERSON_PROPS_ARRAY_OF_KEY_SQL.format(
parsed_date_from=parsed_date_from,
@ -78,7 +78,7 @@ def get_breakdown_event_prop_values(
filter.properties, team_id, table_name="e", filter_test_accounts=filter.filter_test_accounts,
)
entity_params, entity_format_params = get_entity_filtering_params(entity, team_id, with_prop_filters=True)
entity_params, entity_format_params = get_entity_filtering_params(entity, team_id)
elements_query = TOP_ELEMENTS_ARRAY_OF_KEY_SQL.format(
parsed_date_from=parsed_date_from,