0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-28 18:26:15 +01:00
Commit Graph

13 Commits

Author SHA1 Message Date
Rick Marron
2b9917a915
Recordings in paths (#8015)
* add recordings to path query

* uncomment cache

* add clarifying comment

* works for start/end paths

* move to extra fields/properties

* add tests

* cleanup

* update ff name

* fix flaky test

* test and handle path_dropoff_key case
2022-01-18 15:29:52 -08:00
Karl-Aksel Puulmann
784c7d3b08
Related groups query refactor (#7978)
* Resolve weird SQL formatting issue

* Use a discriminated union for ActorType

* Use standard response types for related groups

* Update typing

* Always filter related actors by group type index

* Update snapshots & typing
2022-01-12 13:15:43 +02:00
Rick Marron
a3906d7f1c
Add recordings to trends person modal (#7852)
* add events for recordings to actor response in trends

* order of events doesnt matter in tests

* fix snapshots

* move to recordings objects

* filter to actual recording

* rename include_matched_recordings to include_recordings

* add benchmarks

* remove benchmark

* materialize window and session_id

* add frontend for recordings in person modal

* run prettier

* fix ff query param

* remove session_id + window_id materialization

* cleanup

* fix ts errors

* update snapshots

* fix tests

* rename TrendsPersonQuery -> ClickhouseTrendsActors

* remove flaky snapshot

* clean up should_include_recordings
2022-01-07 14:51:30 -08:00
Eric Duong
34d45e3436
[cohort] insight cohorts (#7569)
* initial working'

* fix tests

* correct tests

* typing

* update snapshot

* add funnel test

* remove unnused

* rest of tests

* function name

* typing

* raise if debugging otherwise send to sentry

* no limit option for cohorts

* remove duplicate

* propogate types correctly

* add param

* cleanup

* update snapshots

* add comment

* change var name

* reverse arg

* use func

* fix tests and types

* add simplify

* move simplification

* adjust checks

* explicit type

* don't init
2022-01-06 10:38:29 -05:00
Karl-Aksel Puulmann
c2bddf09a2
Remove "minute" interval (#7847)
* Remove `minute` interval support from frontend

* Remove minute support from backend, default to hour instead

Also adds tests for interval logic

* Remove now-dead minute support from backend

* revert interval_candidate logic

* Move IntervalMixin to separate file
2022-01-05 13:11:58 +02:00
Eric Duong
4e0e69ac91
[actors] Stickiness actor pattern (#7440)
* separate class

* filter typing

* remove repeat

* refactor test

* add limits

* remove ee

* working tests

* working group tests for stickiness

* remove inits

* suggested changes

* typing

* adjust typing

* add correct params

* remove repeat
2021-12-02 11:43:20 -05:00
Eric Duong
056c3b1973
match filter var name (#7455) 2021-12-01 08:45:04 +02:00
Eric Duong
976e49053a
[groups persons] Funnels groups persons query backend 2 (#7194)
* working for unique_groups math

* fix types

* add null check

* update snapshots

* update payload

* update snapshots

* use constructor

* adjust queries

* introduce base class

* consolidate querying

* shared serializer and typed

* sort imports

* snapshots

* typing

* change name

* Add group model

```sql
BEGIN;
--
-- Create model Group
--
CREATE TABLE "posthog_group" ("id" serial NOT NULL PRIMARY KEY, "group_key" varchar(400) NOT NULL, "group_type_index" integer NOT NULL, "group_properties" jsonb NOT NULL, "created_at" timestamp with time zone NOT NULL, "properties_last_updated_at" jsonb NOT NULL, "properties_last_operation" jsonb NOT NULL, "version" bigint NOT NULL, "team_id" integer NOT NULL);
--
-- Create constraint unique team_id/group_key/group_type_index combo on model group
--
ALTER TABLE "posthog_group" ADD CONSTRAINT "unique team_id/group_key/group_type_index combo" UNIQUE ("team_id", "group_key", "group_type_index");
ALTER TABLE "posthog_group" ADD CONSTRAINT "posthog_group_team_id_b3aed896_fk_posthog_team_id" FOREIGN KEY ("team_id") REFERENCES "posthog_team" ("id") DEFERRABLE INITIALLY DEFERRED;
CREATE INDEX "posthog_group_team_id_b3aed896" ON "posthog_group" ("team_id");
COMMIT;
```

* Remove a dead import

* Improve typing for groups

* Make groups updating more generic, avoid mutation

This simplifies using the same logic for groups

Note there's a behavioral change: We don't produce a new kafka message
if nothing has been updated anymore.

* Rename a function

* WIP: Handle group property updates

... by storing them in postgres

Uses identical pattern to person property updates, except we handle
first-seen case within updates as well.

* Get rid of boolean option

* WIP continued

* fetchGroup() and upsertGroup()

* Test more edge cases

* Add tests for upsertGroup() in properties-updater

* Rename to PropertyUpdateOperation

* Followup

* Solve typing issues

* changed implementation to use pg

* unusd

* update type

* update snapshots

* rename and remove inlining

* restore bad merge code

* adjust types

* add flag

* remove var

* misnamed

* change to uuid

* make sure to use string when passing result

* remove from columnoptimizer logic and have group join logic implemented by event query classes per insight

* add flag to funnel event query

* remove unnecessary logic

* typing

* working actors func

* fix typos

* remove unused func

* use serialized result

* wrong var

* use actors

* remove dead imports

* remove verbosity

* update snapshots

* typos

* remove signals

* remove plugin excess

* update typing

* clean up

* use actor func for all funnel persons

* types

* make sure limits are set

* remove functions

* fix limits

* funnel trends

* types

* indexing

* moved basic funnel tests

* unordered test

* remove duplicate test

* check ids

* more test adjustments

* sort

* change class names

* sort

* reformat

* change string to int

* remove duplicate

* update comment

* use actor result to paginate not serialized

* adjust tests after merging

* simplify typing

* don't import removed func

Co-authored-by: Karl-Aksel Puulmann <oxymaccy@gmail.com>
2021-11-23 09:49:52 -05:00
Eric Duong
7979f52e8a
[groups persons] API for returning groups based on trend results (#7144)
* working for unique_groups math

* fix types

* add null check

* update snapshots

* update payload

* update snapshots

* use constructor

* adjust queries

* introduce base class

* consolidate querying

* shared serializer and typed

* sort imports

* snapshots

* typing

* change name

* Add group model

```sql
BEGIN;
--
-- Create model Group
--
CREATE TABLE "posthog_group" ("id" serial NOT NULL PRIMARY KEY, "group_key" varchar(400) NOT NULL, "group_type_index" integer NOT NULL, "group_properties" jsonb NOT NULL, "created_at" timestamp with time zone NOT NULL, "properties_last_updated_at" jsonb NOT NULL, "properties_last_operation" jsonb NOT NULL, "version" bigint NOT NULL, "team_id" integer NOT NULL);
--
-- Create constraint unique team_id/group_key/group_type_index combo on model group
--
ALTER TABLE "posthog_group" ADD CONSTRAINT "unique team_id/group_key/group_type_index combo" UNIQUE ("team_id", "group_key", "group_type_index");
ALTER TABLE "posthog_group" ADD CONSTRAINT "posthog_group_team_id_b3aed896_fk_posthog_team_id" FOREIGN KEY ("team_id") REFERENCES "posthog_team" ("id") DEFERRABLE INITIALLY DEFERRED;
CREATE INDEX "posthog_group_team_id_b3aed896" ON "posthog_group" ("team_id");
COMMIT;
```

* Remove a dead import

* Improve typing for groups

* Make groups updating more generic, avoid mutation

This simplifies using the same logic for groups

Note there's a behavioral change: We don't produce a new kafka message
if nothing has been updated anymore.

* Rename a function

* WIP: Handle group property updates

... by storing them in postgres

Uses identical pattern to person property updates, except we handle
first-seen case within updates as well.

* Get rid of boolean option

* WIP continued

* fetchGroup() and upsertGroup()

* Test more edge cases

* Add tests for upsertGroup() in properties-updater

* Rename to PropertyUpdateOperation

* Followup

* Solve typing issues

* changed implementation to use pg

* unusd

* update type

* update snapshots

* rename and remove inlining

* restore bad merge code

* adjust types

* add flag

* remove var

* misnamed

* change to uuid

* make sure to use string when passing result

* remove from columnoptimizer logic and have group join logic implemented by event query classes per insight

* remove unnecessary logic

* typing

* remove dead imports

* remove verbosity

* update snapshots

* typos

* remove signals

* remove plugin excess

Co-authored-by: Karl-Aksel Puulmann <oxymaccy@gmail.com>
2021-11-18 11:58:48 -05:00
Eric Duong
b7667f528f
fix issue when breaking down on group property and trying to return persons (#7145) 2021-11-16 09:39:48 +02:00
Eric Duong
df583d528b
6331 pie chart persons bug (#6642)
* backend fixes and test

* add breakdown value to pie chart

* adjust test

* fix faulty test

* fill param

* fix formula tests

* more date passing

* more cleanup

* all tests working

* make test data explicit and add better checks

* support both ee and postgres

* length checks
2021-10-26 14:53:34 -04:00
Karl-Aksel Puulmann
457e151f58
Push person predicates down (#6346)
* Refactor column_optimizer to work differently

* WIP: Use counter over set

* Handle person filters in person query

* Remove a dead argument

* Use enum over parameter for determining behavior

* Allow excluding person properties mode when handled in person query

* Fix _get_person_query type

* Use correct table for funnel_event_query

* Remove unneeded override

* Add extra typing

* Filter by entity.properties in person query for trends

* Handle error 184 due to naming clash

* Better default for prop_filter_json_extract

* Update column_optimizer tests for Counter

* Handle person_props as extra_fields

* Handle breakdowns and person property filter pushdown

* Transform values correctly

* Simplify get_entity_filtering_params

* Fix funnel correlations

* Solve caching issues in trend people queries

* Remove @skip test

* Add syrupy tests for parse_prop_clauses

Can update these via --snapshot-update

* Add snapshot tests for person queries

* Add a few notes

* Update test to avoid collision

* Kill dead code

* Handle PR comments

* Update ee/clickhouse/queries/person_query.py

Co-authored-by: Neil Kakkar <neilkakkar@gmail.com>

Co-authored-by: Neil Kakkar <neilkakkar@gmail.com>
2021-10-13 14:00:47 +00:00
Karl-Aksel Puulmann
a8f46b056b
Refactor and speed up /api/action/people (trends person modal) (#5842)
* Move api/action/people SQL code under ee/clickhouse/queries

* Move api/action/people SQL code into a class

* Fix rebase

* Calculate Trends people via TrendsEventQuery

This should significantly speed up the query. In testing, this took one
query from 10s -> 1s.

We can reuse almost all of the plumbing in TrendsEventQuery.

* Update insert_entity_people_into_cohort

* Fix date handling in trends people, add in-depth tests for each interval

* Standardize code style a bit

* Make tests less TZ dependant

* Skip failing tests on-not-ee

* Document
2021-09-09 09:42:19 +03:00