Exemplo n.º 1
0
    def sessions(self, request: Request, *args: Any,
                 **kwargs: Any) -> Response:
        team = self.team
        filter = SessionsFilter(request=request)

        limit = int(request.GET.get("limit", SESSIONS_LIST_DEFAULT_LIMIT))
        offset = int(request.GET.get("offset", 0))

        response = ClickhouseSessionsList().run(team=team,
                                                filter=filter,
                                                limit=limit + 1,
                                                offset=offset)

        if filter.distinct_id:
            try:
                person_ids = get_persons_by_distinct_ids(
                    team.pk, [filter.distinct_id])[0].distinct_ids
                response = [
                    session for i, session in enumerate(response)
                    if response[i]["distinct_id"] in person_ids
                ]
            except IndexError:
                response = []

        if len(response) > limit:
            response.pop()
            return Response({"result": response, "offset": offset + limit})
        else:
            return Response({
                "result": response,
            })
Exemplo n.º 2
0
    def sessions(self, request: Request, *args: Any,
                 **kwargs: Any) -> Response:  # type: ignore
        filter = SessionsFilter(request=request, team=self.team)

        sessions, pagination = ClickhouseSessionsList.run(team=self.team,
                                                          filter=filter)
        return Response({"result": sessions, "pagination": pagination})
Exemplo n.º 3
0
    def sessions(self, request: Request, *args: Any, **kwargs: Any) -> Response:
        filter = SessionsFilter(request=request)

        sessions, pagination = ClickhouseSessionsList().run(team=self.team, filter=filter)

        if filter.distinct_id:
            try:
                person_ids = get_persons_by_distinct_ids(self.team.pk, [filter.distinct_id])[0].distinct_ids
                sessions = [session for i, session in enumerate(sessions) if session["distinct_id"] in person_ids]
            except IndexError:
                sessions = []

        return Response({"result": sessions, "pagination": pagination})