Skip to content

Commit

Permalink
Align more values
Browse files Browse the repository at this point in the history
  • Loading branch information
webjunkie committed Mar 21, 2024
1 parent 13ab9a3 commit 916cb29
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
10 changes: 10 additions & 0 deletions frontend/src/queries/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,10 @@
},
"type": "object"
},
"DatetimeDay": {
"format": "date-time",
"type": "string"
},
"Day": {
"type": "integer"
},
Expand Down Expand Up @@ -2788,6 +2792,9 @@
{
"type": "string"
},
{
"$ref": "#/definitions/DatetimeDay"
},
{
"$ref": "#/definitions/Day"
}
Expand Down Expand Up @@ -3839,6 +3846,9 @@
{
"type": "string"
},
{
"$ref": "#/definitions/DatetimeDay"
},
{
"$ref": "#/definitions/Day"
}
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/queries/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1179,6 +1179,9 @@ export interface FunnelCorrelationQuery {
response?: FunnelCorrelationResponse
}

/** @format date-time */
export type DatetimeDay = string

export type BreakdownValueInt = integer
export interface InsightActorsQueryOptionsResponse {
day?: { label: string; value: string | Day }[]
Expand Down
5 changes: 1 addition & 4 deletions posthog/hogql_queries/insights/lifecycle_query_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,7 @@ def to_actors_query(

def to_actors_query_options(self) -> InsightActorsQueryOptionsResponse:
return InsightActorsQueryOptionsResponse(
day=[
{"label": format_label_date(value), "value": value.isoformat().replace("+00:00", "Z")}
for value in self.query_date_range.all_values()
],
day=[{"label": format_label_date(value), "value": value} for value in self.query_date_range.all_values()],
status=[
{
"label": "Dormant",
Expand Down
6 changes: 3 additions & 3 deletions posthog/hogql_queries/insights/trends/trends_query_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def to_actors_query_options(self) -> InsightActorsQueryOptionsResponse:
res_days: list[DayItem] = [
DayItem(
label=format_label_date(value, self.query_date_range.interval_name),
value=value.isoformat().replace("+00:00", "Z"),
value=value,
)
for value in self.query_date_range.all_values()
]
Expand Down Expand Up @@ -400,7 +400,7 @@ def get_value(name: str, val: Any):
"label": "All events" if series_label is None else series_label,
"filter": self._query_to_filter(),
"action": { # TODO: Populate missing props in `action`
"days": [value.isoformat() for value in self.query_date_range.all_values()],
"days": self.query_date_range.all_values(),
"id": series_label,
"type": "events",
"order": series.series_order,
Expand Down Expand Up @@ -434,7 +434,7 @@ def get_value(name: str, val: Any):
"label": "All events" if series_label is None else series_label,
"filter": self._query_to_filter(),
"action": { # TODO: Populate missing props in `action`
"days": [value.isoformat() for value in self.query_date_range.all_values()],
"days": self.query_date_range.all_values(),
"id": series_label,
"type": "events",
"order": series.series_order,
Expand Down
6 changes: 5 additions & 1 deletion posthog/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ class DateRange(BaseModel):
date_to: Optional[str] = None


class DatetimeDay(RootModel[AwareDatetime]):
root: AwareDatetime


class Day(RootModel[int]):
root: int

Expand Down Expand Up @@ -457,7 +461,7 @@ class DayItem(BaseModel):
extra="forbid",
)
label: str
value: Union[str, int]
value: Union[str, AwareDatetime, int]


class IntervalItem(BaseModel):
Expand Down

0 comments on commit 916cb29

Please sign in to comment.