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

24 lines
932 B
Python
Raw Normal View History

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))