Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
anirudhpillai committed Sep 3, 2024
1 parent d25afd3 commit df2f5f9
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 42 deletions.
2 changes: 2 additions & 0 deletions cypress/e2e/dashboard.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
10 changes: 4 additions & 6 deletions posthog/api/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down
69 changes: 33 additions & 36 deletions posthog/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
Expand Down

0 comments on commit df2f5f9

Please sign in to comment.