Пример #1
0
    def retention(self, request: request.Request, *args: Any, **kwargs: Any) -> Response:
        team = self.team
        properties = request.GET.get("properties", "{}")

        filter = RetentionFilter(data={"properties": json.loads(properties)})

        start_entity_data = request.GET.get("start_entity", None)
        if start_entity_data:
            data = json.loads(start_entity_data)
            filter.entities = [Entity({"id": data["id"], "type": data["type"]})]

        filter._date_from = "-11d"
        result = retention.Retention().run(filter, team)
        return Response({"data": result})
Пример #2
0
    def retention(self, request: request.Request, *args: Any,
                  **kwargs: Any) -> Response:
        team = self.team
        properties = request.GET.get("properties", "{}")

        try:
            properties = json.loads(properties)
        except json.decoder.JSONDecodeError:
            raise ValidationError("Properties are unparsable!")

        data: Dict[str, Any] = {"properties": properties}
        start_entity_data = request.GET.get("start_entity", None)
        if start_entity_data:
            entity_data = json.loads(start_entity_data)
            data.update({
                "entites": [
                    Entity({
                        "id": entity_data["id"],
                        "type": entity_data["type"]
                    })
                ]
            })

        data.update({"date_from": "-11d"})
        filter = RetentionFilter(data=data)

        result = retention.Retention().run(filter, team)
        return Response({"data": result})