0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-12-01 04:12:23 +01:00
Commit Graph

20 Commits

Author SHA1 Message Date
Michael Matloka
09adf05deb
refactor: Prevent mat columns decorator from being mistaken for a test (#13547)
* refactor: Prevent mat columns decorator from being mistaken for a test

* Rename to `also_test_with_materialized_columns`
2023-01-04 11:28:07 +00:00
Guido Iaquinti
76bae2018d
style(flake8): enable C400,C407,E262 (#13096) 2022-12-05 16:06:54 +01:00
Neil Kakkar
fcdf313e63
fix(retention): Revamp persons modal (#11810)
* fix(retention): Revamp persons modal

* Update snapshots

* clean up & fix things

* Update snapshots

* fix tests, add modal fixes

Co-authored-by: neilkakkar <neilkakkar@users.noreply.github.com>
2022-09-22 10:32:41 -04:00
Michael Matloka
5d2ad6c7bb
chore(deps): Update black to 22.8.0 (#11596)
* chore(deps): Update `black` to `22.8.0`

* Format
2022-09-05 14:38:54 +02:00
Eric Duong
46faa8fab2
refactor(FOSS): foss remove all ee dependencies from /posthog (#10319)
* refactor: foss move properties to /posthog

* refactor: move replication and materializtaion

* refactor: move file

* refactor: move test and journeys

* refactor: move breakdown props

* refactor: move query imports

* refactor: move more ee dependencies

* refactor: restore groupsjoinquery

* fix: errors

* refactor: no ee.clickhouse dependncies

* try import tasks

* refactor: move materialization

* refactor: change foss split for column optimizer

* run black

* fix: imports

* remove comment

* Update snapshots

* run black

* skip isort

* Update snapshots

* format

* more fixes

* refactor(FOSS): split out paths query code (#10378)

* refactor: move migrations

* refactor: move idl

* fix: move more imports

* import adjustments

* fix: test import

* fix: test import

* fix: remove restriction

* refactor: split out paths query code

* refactor: more code splitting

* fix: types

* refactor(FOSS): Setup such that FOSS is deployable (#10352)

* refactor: move migrations

* refactor: move idl

* fix: move more imports

* import adjustments

* fix: test import

* fix: test import

* fix: remove restriction

* fix import

* refactor: add snapshost

* subscription-import

* fix: safe import

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2022-06-22 17:24:03 -04:00
Eric Duong
ce7988ecfa
refactor: move prop value and actorbasequery files (#10258)
* Revert "fix: revert "move prop value and actorbasequery files" due to flaky test (#10257)"

This reverts commit ac1a485cdf.

* chore: empty
2022-06-13 16:24:14 -04:00
Eric Duong
ac1a485cdf
fix: revert "move prop value and actorbasequery files" due to flaky test (#10257)
* Revert "refactor: move prop value and actorbasequery files (#10220)"

This reverts commit 12bf3a7c3e.

* chore: empty
2022-06-10 23:49:53 +00:00
Eric Duong
12bf3a7c3e
refactor: move prop value and actorbasequery files (#10220)
* refactor: move prop value and actorbasequery files

* refactor: move test base

* fix: imports

* move middleware

* refactor: move cohort model util (#10224)
2022-06-10 18:44:50 -04:00
Neil Kakkar
5e09eba801
feat(retention): Enable person on events querying for retention (#9858)
* add constance setting

* add minimum viable code

* update journeys_for

* working test case

* chore: remove eventserializer in unnecessary places

* change execution

* change imports

* fix typing and tests

* change format

* adjust

* reset

* split group path in trend breakdown

* fix: typing

* fix test

* fix test, rename

* automatically add persons to events in tests on flush

* test CI with person-on-events

* wip

* fix

* fix ci

* add comma

* reduce test explosion

* fix CH server image version #9743

* update conditional

* split person on events

* split person on events

* split properly

* fix test deps

* add persons on events for tests

* rm eventserializer changes

* upd

* fix tests

* streamline person on event tests

* remove cache dependence, even after dematerialization deletion

* disregard snapshot tests

* no casting for matrix variables

* fix actions problems

* try to limit blast radius

* Update snapshots

* why are these tests passing?

* stoopid

* fix trend tests

* fix more trend tests, add test for old query regression

* Update snapshots

* optimise persons

* feat(retention): Enable person on events querying for retention

* update snaps

* Update snapshots

* Update snapshots

* fix tests

Co-authored-by: eric <eeoneric@gmail.com>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2022-05-23 16:24:17 -04:00
Karl-Aksel Puulmann
3412eed230
refactor: Remove constance library dependency, use json-encoded model (#9852)
* Populate the new model

* Add constance to admin

* Handle table not existing

* Add model tests

* Add tests for the constance model

* Fixup migrations

* Update instance settings to use new constance model

* update most readings

* Use override method in some tests

* Improve typing

* Prettier

* Merge 233 migration

* Order imports

* Fixup

* Update some query counts

* Remove dead import

* Improve some mypy

* Update team.py

* Remove constance library

* Mark migration as non-atomic

* Instance settings cleanup

* Rename methods to be more consistent

* Fixup for migration

* Update tests
2022-05-20 15:12:37 +03:00
Neil Kakkar
2fe2f8352a
fix(retention): Fix persons call for retention (#8947) 2022-03-10 12:17:41 +00:00
Guido Iaquinti
0ef7f6a493
ci(flake8): enable unused import check (#8714) 2022-03-08 09:53:54 +01:00
Guido Iaquinti
126cd4c463
Remove mutable dataclasses (#8645) 2022-02-17 10:12:09 +01:00
Eric Duong
dc0fa2dc6d
fix(retention): actor bug (#8079)
* add team param

* move test

* restore
2022-01-18 12:05:47 -05:00
Harry Waye
83386a5512
fix(retention): add regression test for not_icontains filter (#7748)
* fix(retention): add regression test for not_icontains filter

Previously if using the not_icontains filter, we were trying to double
substitute a query when fetching persons for retention. This adds a
test (and in the next commit a fix) such that we instead apply the
clickhouse substitute only once to each part of the query.

Resolves https://github.com/PostHog/posthog/issues/7747

* avoid double substitution

* Rework solution to not change ActorBaseQuery interface

* Remove unued import

* fix typing
2021-12-17 10:13:38 +00:00
Harry Waye
c595976779
fix(retention): fix breakdown people urls (#7642)
* fix(retention): fix breakdown people urls

This change returns people_url for each breakdown cohort in the
response. We also merge the initial and returning queries together,
as this makes it easier to align the people query also.

Note that I'm talking about person_id as opposed to actor_type etc.
but perhaps that can be a followup.

* clean up clickhouse params

* tidy up a little

* remove import

* remove non-breakdown specific code

* make cohort by initial event date a special breakdown case

* keep date for backwards compat

* Remove unused sql

* make test stable

* wip

* Get most of the tests working

* test(retention): remove graph retention test

We no longer need this, we have all the information we need from the
table response for retention, and can construct this on the frontend.

* revert any changes to posthog/queries/retention.py

* revert any changes to ee/clickhouse/models/person.py

* Revert posthog/queries/retention.py to merge-base

* Ensure actor id is a str

* Add type for actor serialiser for type narrowing

* run black

* sort imports

* Remove retention_actors.py

* fix typings

* format

* reverse str type

* sort imports

* rename

* split out functions

* remove deuplicate logic

* working

* fix type

* don't stringify

* fix test

* ordering doesn't matter

* trigger ci

Co-authored-by: eric <eeoneric@gmail.com>
2021-12-15 18:20:56 +00:00
Harry Waye
b94d02bc10
test(retention): add test for retention breakdown with materialized property (#7505)
* test(retention): add test for retention breakdown with materialized property

* remove unused imports

* Join tables based on breakdowns properties
2021-12-07 15:05:03 +00:00
Harry Waye
79816a9715
feat(retention): add support for multiple breakdown props (#7431)
* test(retention): add http api tests for retention breakdowns

This just adds tests for person and event property breakdowns

* Add helper function for substituting clickhouse sql params

* feat(retention): add support for multiple breakdown props

This just reuses the work done for funnel multiple breakdown values. I
haven't tested this with anything other than person or event properties.
Rather than try to get it working for all the other property types.

The change adds a new `breakdowns` parameter to the retention endpoint,
that is the same as for funnels, e.g. it looks like:

```
{
    ...
    "breakdowns": [{"type": "person", "property": "os"}, ...]
    ...
}
```

The return structure is the same as the non-breakdown version, except we
also include a `breakdown_values` property that is e.g. `["Chrome",
"95"]`, and the `label` attribute for this case would be "Chrome::95".

* fix typing

* update query snapshots

* remove unused imports

* use `self.assertEqual` instead of `assert`

* Remove explicit should_join_persons

* Revert limit by changes, use breakdown_type

* update snapshots

* fix typing

* use json_encode_request_params in retention test requests

* update json_encode_request_params to encode_get_request_params to better reflect purpose

* perf(retention): add benchmark query for retention with breakdown

* no materialize
2021-12-02 13:35:33 +00: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
Harry Waye
60961ae78b
refactor(retention): Adds people_urls to retention trends response (#7184)
* Addtest for people_urls in retention trend response

* Add people_urls to retention trend response

* Run black formater

* sort imports

* Add default value for base_uri

* Let type be missing in EventPattern in tests

TypedDict is so rubbish in not allowing missing attributes 🤷

* fix typing

* refactor creation helper functions

* revert docker compose change
2021-11-19 10:25:58 +00:00