-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Clickhouse] Event list #1787
[Clickhouse] Event list #1787
Conversation
…query if opening an url with a filter
…(was: show sign if exactly LIMIT fetched)
…6-2-event-list * origin/clickhouse-sessions-qa: (24 commits) remove reverse add default time to fix test, fix some any(*) filter issues fix test mypy fix pagination, timestamp calculation and ordering on pages 2 and beyond show seconds with two digits add person properties to sessions query response add elements to query results events in clickhouse sessions default limit to 50 based offset is always 0 load LIMIT+1 sessions in postgres, pop last and show load more sign. (was: show sign if exactly LIMIT fetched) support limit + offset indent sql initial limit/offset block rename offset to nextOffset date from filters throw error if failed instead of returning an empty list prevent multiple queries load sessions based on the URL, not after mount --> avoids duplicate query if opening an url with a filter ...
@@ -32,7 +32,7 @@ services: | |||
CLICKHOUSE_VERIFY: 'False' | |||
KAFKA_URL: 'kafka://kafka' | |||
REDIS_URL: 'redis://redis:6379/' | |||
SECRET_KEY: '<randomly generated secret key>' | |||
SECRET_KEY: 'alsdfjiosdajfklalsdjkf' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For what it's worth only we will be using this docker-compose file. This is not for general consumption.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm yeah that's true... I guess it's not a problem then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yep I didn't mean to commit this but it was annoying. If James G is happy I can leave this in
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yep I didn't mean to commit this but it was annoying. If James G is happy I can leave this in
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah doesn't bother me any
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks awesome. Send it! (with comments lol)
@@ -3,4 +3,4 @@ | |||
set -e | |||
python manage.py migrate | |||
|
|||
python manage.py runserver 0.0.0.0:8000 & ./bin/start-frontend 0.0.0.0 | |||
python manage.py runserver 0.0.0.0:8000 & ./bin/start-frontend 127.0.0.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing hits what yarn run start-http
runs correct? If so this is great
# install dev dependencies | ||
RUN pip install -r requirements/dev.txt --compile | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome
@@ -13,7 +13,7 @@ def parse_filter(filters: List[Property]) -> Tuple[str, Dict]: | |||
result = "" | |||
params = {} | |||
for idx, prop in enumerate(filters): | |||
result += "{cond}(ep.key = %(k{idx})s) AND (ep.value = %(v{idx})s)".format( | |||
result += "{cond}(ep.key = %(k{idx})s) AND (trim(BOTH '\"' FROM ep.value) = %(v{idx})s)".format( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd leave this out for now. It's better to add this to the materialized view on clickhouse so that we don't have to clean anything up in post.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm tests fail/you won't be able to filter without this. Is it easy to add it to materliazed view?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep this in for now... but I'd like to get that solved at the source as quickly as possible. When we change serialization from JSON to Avro or Proto this will be cleaned up upstream
events_with_array_props_view ewap | ||
INNER JOIN person_distinct_id as pid ON ewap.distinct_id = pid.distinct_id | ||
INNER JOIN person ON pid.person_id = person.id | ||
where ewap.team_id = %(team_id)s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: inConSISTent CapS
from posthog.utils import convert_property_value | ||
|
||
|
||
class ClickhouseEvents(EventViewSet): | ||
def list(self, request): | ||
def _get_elements(self, query_result: List[Dict], team: Team) -> Dict[str, Any]: | ||
element_hashes = [event[6] for event in query_result] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really don't like that we are pulling out hashes by index 6
here. Has a bit of a smell. Not a huge deal though. If we did this in a few spots it would make it really hard to refactor the query and reorder columns.
Would be better if we had event.element_hash
on the row. Something we can work towards.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah agree, need to solve this. surprised the driver doesn't give you a dict or object
INNER JOIN person_distinct_id as pid ON ewap.distinct_id = pid.distinct_id | ||
INNER JOIN person ON pid.person_id = person.id | ||
where ewap.team_id = %(team_id)s | ||
AND ewap.uuid IN (select uuid from events WHERE team_id = %(team_id)s {conditions}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: inConSISTent CapS
) {conditions} {limit} | ||
WHERE team_id = %(team_id)s AND {filters} | ||
) | ||
AND ewap.uuid IN (select uuid from events WHERE team_id = %(team_id)s {conditions}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: inConSISTent CapS
) | ||
|
||
with self.assertNumQueries(7): | ||
def test_event_api_factory(event_factory, person_factory, action_factory): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀 very nice
Changes
Please describe.
If this affects the front-end, include screenshots.
Checklist