Skip to content

Commit

Permalink
feat: lifecycle query runner class (#17440)
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusandra authored Sep 15, 2023
1 parent d7a97f8 commit 35b0adf
Show file tree
Hide file tree
Showing 7 changed files with 377 additions and 247 deletions.
10 changes: 5 additions & 5 deletions posthog/api/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@
from posthog.hogql.errors import HogQLException
from posthog.hogql.metadata import get_hogql_metadata
from posthog.hogql.query import execute_hogql_query
from posthog.hogql_queries.lifecycle_hogql_query import run_lifecycle_query

from posthog.hogql_queries.lifecycle_query_runner import LifecycleQueryRunner
from posthog.models import Team
from posthog.models.event.events_query import run_events_query
from posthog.models.user import User
from posthog.permissions import ProjectMembershipNecessaryPermissions, TeamMemberAccessPermission
from posthog.queries.time_to_see_data.serializers import SessionEventsQuerySerializer, SessionsQuerySerializer
from posthog.queries.time_to_see_data.sessions import get_session_events, get_sessions
from posthog.rate_limit import AIBurstRateThrottle, AISustainedRateThrottle, TeamRateThrottle
from posthog.schema import EventsQuery, HogQLQuery, HogQLMetadata, LifecycleQuery
from posthog.schema import EventsQuery, HogQLQuery, HogQLMetadata


class QueryThrottle(TeamRateThrottle):
Expand Down Expand Up @@ -221,9 +222,8 @@ def process_query(team: Team, query_json: Dict, default_limit: Optional[int] = N
metadata_response = get_hogql_metadata(query=metadata_query, team=team)
return _unwrap_pydantic_dict(metadata_response)
elif query_kind == "LifecycleQuery":
lifecycle_query = LifecycleQuery.parse_obj(query_json)
lifecycle_response = run_lifecycle_query(query=lifecycle_query, team=team)
return _unwrap_pydantic_dict(lifecycle_response)
lifecycle_query_runner = LifecycleQueryRunner(query_json, team)
return _unwrap_pydantic_dict(lifecycle_query_runner.run())
elif query_kind == "DatabaseSchemaQuery":
database = create_hogql_database(team.pk)
return serialize_database(database)
Expand Down
237 changes: 0 additions & 237 deletions posthog/hogql_queries/lifecycle_hogql_query.py

This file was deleted.

Loading

0 comments on commit 35b0adf

Please sign in to comment.