-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(insights): HogQL calculation of saved legacy insights v2 (#21595)
* fix(insights): HogQL calculation of saved legacy insights v2 This reverts commit a6314c6. * Only use cached results in `process_query` for insight serializer * Fix type of results * Rename `RecalculationMode` to `ExecutionMode` * Fix typing more * Properly support dashboard filters * Hacky fix for schema.py * Don't test legacy `generate_insight_cache_key` with `query` * Fix importing & typing * Fix typo * Update test_query_runner.py * Account for property filter groups in dashboard filters * Do return stale result in CACHE_ONLY case * Fix `execute_hogql_query` espionage Wow, this was a pain to figure out, only was an issue in CI, because the trigger was `TestCohort::test_creating_update_and_calculating_with_new_cohort_query` running prior to `TestInsight:: test_insight_refreshing_query` – had to use trial and error. * Fix typing even more * Don't require `pnpm` for `schema:build:python` Matters in CI. * Fix `schema:build:python` * Fix sed usage * Move `schema:build:python` to a bash script * Validate cache properly Clarifies the `cached_response.is_cached = True` situation. * Fix Python formatting * Update UI snapshots for `webkit` (2) * Add test to ensure /query/ and /inisghts/ use the same cache * Update mypy-baseline.txt --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
1df7232
commit 3e2d28f
Showing
31 changed files
with
555 additions
and
321 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
# Generate schema.py from schema.json | ||
datamodel-codegen \ | ||
--class-name='SchemaRoot' --collapse-root-models --target-python-version 3.10 --disable-timestamp \ | ||
--use-one-literal-as-default --use-default --use-default-kwarg --use-subclass-enum \ | ||
--input frontend/src/queries/schema.json --input-file-type jsonschema \ | ||
--output posthog/schema.py --output-model-type pydantic_v2.BaseModel | ||
|
||
# Format schema.py | ||
ruff format posthog/schema.py | ||
|
||
# Check schema.py and autofix | ||
ruff check --fix posthog/schema.py | ||
|
||
# HACK: Datamodel-codegen output for enum-type fields with a default is invalid – the default value is a plain string, | ||
# and not the expected enum member. We fix this using sed, which is pretty hacky, but does the job. | ||
# Specifically, we need to replace `Optional[PropertyOperator] = "exact"` | ||
# with `Optional[PropertyOperator] = PropertyOperator("exact")` to make the default value valid. | ||
# Remove this when https://github.com/koxudaxi/datamodel-code-generator/issues/1929 is resolved. | ||
if [[ "$OSTYPE" == "darwin"* ]]; then | ||
# sed needs `-i` to be followed by `''` on macOS | ||
sed -i '' -e 's/Optional\[PropertyOperator\] = \("[A-Za-z_]*"\)/Optional[PropertyOperator] = PropertyOperator(\1)/g' posthog/schema.py | ||
else | ||
sed -i -e 's/Optional\[PropertyOperator\] = \("[A-Za-z_]*"\)/Optional[PropertyOperator] = PropertyOperator(\1)/g' posthog/schema.py | ||
fi |
Binary file modified
BIN
+830 Bytes
(100%)
...ts__/scenes-app-insights--funnel-top-to-bottom-breakdown-edit--dark--webkit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+886 Bytes
(100%)
...s__/scenes-app-insights--funnel-top-to-bottom-breakdown-edit--light--webkit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.