0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-24 18:07:17 +01:00
posthog/ee/api/time_to_see_data.py
Karl-Aksel Puulmann d4a13b6c9b
feat(make-pain-visible): backend (#13470)
* Improve query metrics SQL

* Track primary interactions

* Scaffolding for time_to_see_data api

* Query list of sessions

* schema fixup

* Fetch more user and team info

* Fetch a single sessions events

* Update naming

* Separate file for serializers

* Return information on session to session events

* Gather session_id for queries

* Gather queries for sessions

* primary_interaction_id

* Remove list special-casing

* Rename a type in fe

* Remove duplication

* Frontend data node for session events

* Separate component for TimeToSeeData

* Update queries

* Slightly better rendering

* Tests for is_child

* Tests for construct_hierarchy

* Test _sessions_condition

* Test /api/time_to_see_data/sessions

* Create api tests for session events

* Format with prettier

* Hack some typing

* Solve a typing issue

* add some annotations
2022-12-30 07:31:15 +02:00

24 lines
932 B
Python

from rest_framework import viewsets
from rest_framework.decorators import action
from rest_framework.response import Response
from posthog.permissions import IsStaffUser
from posthog.queries.time_to_see_data.serializers import SessionEventsQuerySerializer, SessionsQuerySerializer
from posthog.queries.time_to_see_data.sessions import get_session_events, get_sessions
class TimeToSeeDataViewSet(viewsets.ViewSet):
permission_classes = [IsStaffUser]
@action(methods=["POST"], detail=False)
def sessions(self, request):
query = SessionsQuerySerializer(data=request.data)
query.is_valid(raise_exception=True)
return Response(get_sessions(query).data)
@action(methods=["POST"], detail=False)
def session_events(self, request):
query = SessionEventsQuerySerializer(data=request.data)
query.is_valid(raise_exception=True)
return Response(get_session_events(query))