From df2f5f927dcc3bd9592fd508799d8d3c4456c7b0 Mon Sep 17 00:00:00 2001 From: Anirudh Pillai Date: Tue, 3 Sep 2024 17:32:56 +0100 Subject: [PATCH] lint --- cypress/e2e/dashboard.cy.ts | 2 ++ posthog/api/query.py | 10 +++--- posthog/schema.py | 69 ++++++++++++++++++------------------- 3 files changed, 39 insertions(+), 42 deletions(-) diff --git a/cypress/e2e/dashboard.cy.ts b/cypress/e2e/dashboard.cy.ts index 0d018d468f38b3..cc12b00be2a944 100644 --- a/cypress/e2e/dashboard.cy.ts +++ b/cypress/e2e/dashboard.cy.ts @@ -413,6 +413,8 @@ describe('Dashboard', () => { cy.get('[data-attr="date-filter"]').click() cy.contains('span', 'Last 14 days').click() + cy.wait(1000) + // insight meta should be updated to show new date range // default date range is last 7 days cy.get('h5').contains('Last 14 days').should('exist') diff --git a/posthog/api/query.py b/posthog/api/query.py index 5fbae339142b65..c91e6eb36bd8cf 100644 --- a/posthog/api/query.py +++ b/posthog/api/query.py @@ -27,10 +27,9 @@ from posthog.hogql_queries.query_runner import ExecutionMode, execution_mode_from_refresh from posthog.models.user import User from posthog.rate_limit import AIBurstRateThrottle, AISustainedRateThrottle, PersonalApiKeyRateThrottle -from posthog.schema import QueryRequest, QueryResponseAlternative, QueryStatusResponse, QueryType +from posthog.schema import QueryRequest, QueryResponseAlternative, QueryStatusResponse from posthog.api.monitoring import monitor, Feature from posthog.hogql_queries.apply_dashboard_filters import apply_dashboard_filters_to_dict -from typing import cast class QueryThrottle(PersonalApiKeyRateThrottle): @@ -62,10 +61,9 @@ def get_throttles(self): def create(self, request, *args, **kwargs) -> Response: data = self.get_model(request.data, QueryRequest) if data.filters_override is not None: - data.query = cast( - QueryType, - apply_dashboard_filters_to_dict(data.query.model_dump(), data.filters_override.model_dump(), self.team), - ) + data.query = apply_dashboard_filters_to_dict( + data.query.model_dump(), data.filters_override.model_dump(), self.team + ) # type: ignore client_query_id = data.client_query_id or uuid.uuid4().hex execution_mode = execution_mode_from_refresh(data.refresh) diff --git a/posthog/schema.py b/posthog/schema.py index 8d67696bee8582..81638c5ee0ff7c 100644 --- a/posthog/schema.py +++ b/posthog/schema.py @@ -5548,41 +5548,6 @@ class HogQLMetadata(BaseModel): ) -QueryType = Union[ - EventsNode, - ActionsNode, - PersonsNode, - DataWarehouseNode, - EventsQuery, - ActorsQuery, - InsightActorsQuery, - InsightActorsQueryOptions, - SessionsTimelineQuery, - HogQuery, - HogQLQuery, - HogQLMetadata, - HogQLAutocomplete, - WebOverviewQuery, - WebStatsTableQuery, - WebTopClicksQuery, - WebGoalsQuery, - SessionAttributionExplorerQuery, - ErrorTrackingQuery, - DataVisualizationNode, - DataTableNode, - SavedInsightNode, - InsightVizNode, - TrendsQuery, - FunnelsQuery, - RetentionQuery, - PathsQuery, - StickinessQuery, - LifecycleQuery, - FunnelCorrelationQuery, - DatabaseSchemaQuery, -] - - class QueryRequest(BaseModel): model_config = ConfigDict( extra="forbid", @@ -5599,7 +5564,39 @@ class QueryRequest(BaseModel): client_query_id: Optional[str] = Field( default=None, description="Client provided query ID. Can be used to retrieve the status or cancel the query." ) - query: QueryType = Field( + query: Union[ + EventsNode, + ActionsNode, + PersonsNode, + DataWarehouseNode, + EventsQuery, + ActorsQuery, + InsightActorsQuery, + InsightActorsQueryOptions, + SessionsTimelineQuery, + HogQuery, + HogQLQuery, + HogQLMetadata, + HogQLAutocomplete, + WebOverviewQuery, + WebStatsTableQuery, + WebTopClicksQuery, + WebGoalsQuery, + SessionAttributionExplorerQuery, + ErrorTrackingQuery, + DataVisualizationNode, + DataTableNode, + SavedInsightNode, + InsightVizNode, + TrendsQuery, + FunnelsQuery, + RetentionQuery, + PathsQuery, + StickinessQuery, + LifecycleQuery, + FunnelCorrelationQuery, + DatabaseSchemaQuery, + ] = Field( ..., description=( "Submit a JSON string representing a query for PostHog data analysis, for example a HogQL query.\n\nExample"