0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-12-01 04:12:23 +01:00
posthog/ee/api/time_to_see_data.py
Tom Owers 5513be7731
chore: upgraded Ruff linter (#18188)
* Upgraded Ruff linter

* Formatted whole codebase with new ruff rules

* Revert import removal

* Fixed mypi issues or added ignores

* Fixed schema formatting

* Fixed hogvm failing tests

* Remove duplicate key in list
2023-10-26 12:38:15 +02:00

27 lines
945 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))