mirror of
https://github.com/PostHog/posthog.git
synced 2024-11-29 03:04:16 +01:00
4ece4ce3e8
* split params into mixins * add typing * split func * dedicated paths filter * make basefilter * restructure directories * move prop mixin * implement cached_property and fix circular import * remove unused imports * stickiness filter converted * temp patch for breakdown * correct naming for derived mixins in paths * fix types * fix types * fix casing * fix breakdown arg * merge master * add to_dict * DRY to_dict * scoped to_dict ability * fix types * add missing fields * refactor session filter * remove unused imports * remove unused imports * add stickiness filter test * fix dict for pathfilter * properly load strs * add default * standardize loading * retention filter separate * add update filter to retention * change back decorator * don't allow setting on filter date_from date_to * remove seconds on default timestamp * remove derived values * fix date formatting * fix typo
35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
from django.db import connection
|
|
from rest_framework import request, viewsets
|
|
from rest_framework.decorators import action
|
|
from rest_framework.response import Response
|
|
|
|
from ee.clickhouse.client import sync_execute
|
|
from ee.clickhouse.queries.clickhouse_paths import ClickhousePaths
|
|
from ee.clickhouse.sql.events import ELEMENT_TAG_COUNT
|
|
from posthog.api.paths import PathsViewSet
|
|
from posthog.models import Event, Filter
|
|
from posthog.models.filters.path_filter import PathFilter
|
|
|
|
|
|
class ClickhousePathsViewSet(PathsViewSet):
|
|
@action(methods=["GET"], detail=False)
|
|
def elements(self, request: request.Request, **kwargs):
|
|
|
|
team = self.team
|
|
response = sync_execute(ELEMENT_TAG_COUNT, {"team_id": team.pk, "limit": 20})
|
|
|
|
resp = []
|
|
for row in response:
|
|
resp.append({"name": row[0], "id": row[1], "count": row[2]})
|
|
|
|
return Response(resp)
|
|
|
|
# FIXME: Timestamp is timezone aware timestamp, date range uses naive date.
|
|
# To avoid unexpected results should convert date range to timestamps with timezone.
|
|
def list(self, request, **kwargs):
|
|
|
|
team = self.team
|
|
filter = PathFilter(request=request)
|
|
resp = ClickhousePaths().run(filter=filter, team=team)
|
|
return Response(resp)
|