We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Missing application names under 'Apps with most usage'
**Describe the bug**
After upgrading to 2023.8.1, the 'Apps with most usage' table no longer shows any application names.

**To Reproduce**
Steps to reproduce the behavior:

1. Log in with an administrator account
2. Go to the Admin Interface
3. See 'Apps with most usage'. The table will be present, with correct data, but the `Application` column is empty

**Expected behavior**
The `Application` column should contain the correct application names.

**Screenshots**
<img width="402" alt="Screenshot 2023-08-30 at 11 52 14" src="https://github.com/goauthentik/authentik/assets/1585352/d71ffa8b-e055-4161-9210-c6711fff0a92">

**Logs**
N/A

**Version and Deployment:**

-   authentik version: 2023.8.1
-   Deployment: Docker Compose

**Additional context**

The underlying cause seems to be a serialization error in the `/api/v3/events/events/top_per_user/?action=authorize_application&top_n=11` endpoint. The `application` field is serialized as a string, rather than an object, as shown in the following screenshot:

<img width="729" alt="Screenshot 2023-08-30 at 11 56 35" src="https://github.com/goauthentik/authentik/assets/1585352/5315f79d-9952-496a-b525-9981884154fb">





--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `authentik/events/api/events.py`
Content:
```
1 """Events API Views"""
2 from datetime import timedelta
3 from json import loads
4 
5 import django_filters
6 from django.db.models.aggregates import Count
7 from django.db.models.fields.json import KeyTextTransform
8 from django.db.models.functions import ExtractDay
9 from drf_spectacular.types import OpenApiTypes
10 from drf_spectacular.utils import OpenApiParameter, extend_schema
11 from guardian.shortcuts import get_objects_for_user
12 from rest_framework.decorators import action
13 from rest_framework.fields import DictField, IntegerField
14 from rest_framework.request import Request
15 from rest_framework.response import Response
16 from rest_framework.serializers import ModelSerializer
17 from rest_framework.viewsets import ModelViewSet
18 
19 from authentik.admin.api.metrics import CoordinateSerializer
20 from authentik.core.api.utils import PassiveSerializer, TypeCreateSerializer
21 from authentik.events.models import Event, EventAction
22 
23 
24 class EventSerializer(ModelSerializer):
25     """Event Serializer"""
26 
27     class Meta:
28         model = Event
29         fields = [
30             "pk",
31             "user",
32             "action",
33             "app",
34             "context",
35             "client_ip",
36             "created",
37             "expires",
38             "tenant",
39         ]
40 
41 
42 class EventTopPerUserSerializer(PassiveSerializer):
43     """Response object of Event's top_per_user"""
44 
45     application = DictField()
46     counted_events = IntegerField()
47     unique_users = IntegerField()
48 
49 
50 class EventsFilter(django_filters.FilterSet):
51     """Filter for events"""
52 
53     username = django_filters.CharFilter(
54         field_name="user", lookup_expr="username", label="Username"
55     )
56     context_model_pk = django_filters.CharFilter(
57         field_name="context",
58         lookup_expr="model__pk",
59         label="Context Model Primary Key",
60         method="filter_context_model_pk",
61     )
62     context_model_name = django_filters.CharFilter(
63         field_name="context",
64         lookup_expr="model__model_name",
65         label="Context Model Name",
66     )
67     context_model_app = django_filters.CharFilter(
68         field_name="context", lookup_expr="model__app", label="Context Model App"
69     )
70     context_authorized_app = django_filters.CharFilter(
71         field_name="context",
72         lookup_expr="authorized_application__pk",
73         label="Context Authorized application",
74     )
75     action = django_filters.CharFilter(
76         field_name="action",
77         lookup_expr="icontains",
78     )
79     tenant_name = django_filters.CharFilter(
80         field_name="tenant",
81         lookup_expr="name",
82         label="Tenant name",
83     )
84 
85     def filter_context_model_pk(self, queryset, name, value):
86         """Because we store the PK as UUID.hex,
87         we need to remove the dashes that a client may send. We can't use a
88         UUIDField for this, as some models might not have a UUID PK"""
89         value = str(value).replace("-", "")
90         return queryset.filter(context__model__pk=value)
91 
92     class Meta:
93         model = Event
94         fields = ["action", "client_ip", "username"]
95 
96 
97 class EventViewSet(ModelViewSet):
98     """Event Read-Only Viewset"""
99 
100     queryset = Event.objects.all()
101     serializer_class = EventSerializer
102     ordering = ["-created"]
103     search_fields = [
104         "event_uuid",
105         "user",
106         "action",
107         "app",
108         "context",
109         "client_ip",
110     ]
111     filterset_class = EventsFilter
112 
113     @extend_schema(
114         methods=["GET"],
115         responses={200: EventTopPerUserSerializer(many=True)},
116         filters=[],
117         parameters=[
118             OpenApiParameter(
119                 "action",
120                 type=OpenApiTypes.STR,
121                 location=OpenApiParameter.QUERY,
122                 required=False,
123             ),
124             OpenApiParameter(
125                 "top_n",
126                 type=OpenApiTypes.INT,
127                 location=OpenApiParameter.QUERY,
128                 required=False,
129             ),
130         ],
131     )
132     @action(detail=False, methods=["GET"], pagination_class=None)
133     def top_per_user(self, request: Request):
134         """Get the top_n events grouped by user count"""
135         filtered_action = request.query_params.get("action", EventAction.LOGIN)
136         top_n = int(request.query_params.get("top_n", "15"))
137         return Response(
138             get_objects_for_user(request.user, "authentik_events.view_event")
139             .filter(action=filtered_action)
140             .exclude(context__authorized_application=None)
141             .annotate(application=KeyTextTransform("authorized_application", "context"))
142             .annotate(user_pk=KeyTextTransform("pk", "user"))
143             .values("application")
144             .annotate(counted_events=Count("application"))
145             .annotate(unique_users=Count("user_pk", distinct=True))
146             .values("unique_users", "application", "counted_events")
147             .order_by("-counted_events")[:top_n]
148         )
149 
150     @extend_schema(
151         methods=["GET"],
152         responses={200: CoordinateSerializer(many=True)},
153         filters=[],
154         parameters=[
155             OpenApiParameter(
156                 "action",
157                 type=OpenApiTypes.STR,
158                 location=OpenApiParameter.QUERY,
159                 required=False,
160             ),
161             OpenApiParameter(
162                 "query",
163                 type=OpenApiTypes.STR,
164                 location=OpenApiParameter.QUERY,
165                 required=False,
166             ),
167         ],
168     )
169     @action(detail=False, methods=["GET"], pagination_class=None)
170     def per_month(self, request: Request):
171         """Get the count of events per month"""
172         filtered_action = request.query_params.get("action", EventAction.LOGIN)
173         try:
174             query = loads(request.query_params.get("query", "{}"))
175         except ValueError:
176             return Response(status=400)
177         return Response(
178             get_objects_for_user(request.user, "authentik_events.view_event")
179             .filter(action=filtered_action)
180             .filter(**query)
181             .get_events_per(timedelta(weeks=4), ExtractDay, 30)
182         )
183 
184     @extend_schema(responses={200: TypeCreateSerializer(many=True)})
185     @action(detail=False, pagination_class=None, filter_backends=[])
186     def actions(self, request: Request) -> Response:
187         """Get all actions"""
188         data = []
189         for value, name in EventAction.choices:
190             data.append({"name": name, "description": "", "component": value, "model_name": ""})
191         return Response(TypeCreateSerializer(data, many=True).data)
192
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/authentik/events/api/events.py b/authentik/events/api/events.py
--- a/authentik/events/api/events.py
+++ b/authentik/events/api/events.py
@@ -4,7 +4,7 @@
 
 import django_filters
 from django.db.models.aggregates import Count
-from django.db.models.fields.json import KeyTextTransform
+from django.db.models.fields.json import KeyTextTransform, KeyTransform
 from django.db.models.functions import ExtractDay
 from drf_spectacular.types import OpenApiTypes
 from drf_spectacular.utils import OpenApiParameter, extend_schema
@@ -134,11 +134,11 @@
         """Get the top_n events grouped by user count"""
         filtered_action = request.query_params.get("action", EventAction.LOGIN)
         top_n = int(request.query_params.get("top_n", "15"))
-        return Response(
+        events = (
             get_objects_for_user(request.user, "authentik_events.view_event")
             .filter(action=filtered_action)
             .exclude(context__authorized_application=None)
-            .annotate(application=KeyTextTransform("authorized_application", "context"))
+            .annotate(application=KeyTransform("authorized_application", "context"))
             .annotate(user_pk=KeyTextTransform("pk", "user"))
             .values("application")
             .annotate(counted_events=Count("application"))
@@ -146,6 +146,7 @@
             .values("unique_users", "application", "counted_events")
             .order_by("-counted_events")[:top_n]
         )
+        return Response(EventTopPerUserSerializer(instance=events, many=True).data)
 
     @extend_schema(
         methods=["GET"],

{"golden_diff": "diff --git a/authentik/events/api/events.py b/authentik/events/api/events.py\n--- a/authentik/events/api/events.py\n+++ b/authentik/events/api/events.py\n@@ -4,7 +4,7 @@\n \n import django_filters\n from django.db.models.aggregates import Count\n-from django.db.models.fields.json import KeyTextTransform\n+from django.db.models.fields.json import KeyTextTransform, KeyTransform\n from django.db.models.functions import ExtractDay\n from drf_spectacular.types import OpenApiTypes\n from drf_spectacular.utils import OpenApiParameter, extend_schema\n@@ -134,11 +134,11 @@\n         \"\"\"Get the top_n events grouped by user count\"\"\"\n         filtered_action = request.query_params.get(\"action\", EventAction.LOGIN)\n         top_n = int(request.query_params.get(\"top_n\", \"15\"))\n-        return Response(\n+        events = (\n             get_objects_for_user(request.user, \"authentik_events.view_event\")\n             .filter(action=filtered_action)\n             .exclude(context__authorized_application=None)\n-            .annotate(application=KeyTextTransform(\"authorized_application\", \"context\"))\n+            .annotate(application=KeyTransform(\"authorized_application\", \"context\"))\n             .annotate(user_pk=KeyTextTransform(\"pk\", \"user\"))\n             .values(\"application\")\n             .annotate(counted_events=Count(\"application\"))\n@@ -146,6 +146,7 @@\n             .values(\"unique_users\", \"application\", \"counted_events\")\n             .order_by(\"-counted_events\")[:top_n]\n         )\n+        return Response(EventTopPerUserSerializer(instance=events, many=True).data)\n \n     @extend_schema(\n         methods=[\"GET\"],\n", "issue": "Missing application names under 'Apps with most usage'\n**Describe the bug**\r\nAfter upgrading to 2023.8.1, the 'Apps with most usage' table no longer shows any application names.\r\n\r\n**To Reproduce**\r\nSteps to reproduce the behavior:\r\n\r\n1. Log in with an administrator account\r\n2. Go to the Admin Interface\r\n3. See 'Apps with most usage'. The table will be present, with correct data, but the `Application` column is empty\r\n\r\n**Expected behavior**\r\nThe `Application` column should contain the correct application names.\r\n\r\n**Screenshots**\r\n<img width=\"402\" alt=\"Screenshot 2023-08-30 at 11 52 14\" src=\"https://github.com/goauthentik/authentik/assets/1585352/d71ffa8b-e055-4161-9210-c6711fff0a92\">\r\n\r\n**Logs**\r\nN/A\r\n\r\n**Version and Deployment:**\r\n\r\n-   authentik version: 2023.8.1\r\n-   Deployment: Docker Compose\r\n\r\n**Additional context**\r\n\r\nThe underlying cause seems to be a serialization error in the `/api/v3/events/events/top_per_user/?action=authorize_application&top_n=11` endpoint. The `application` field is serialized as a string, rather than an object, as shown in the following screenshot:\r\n\r\n<img width=\"729\" alt=\"Screenshot 2023-08-30 at 11 56 35\" src=\"https://github.com/goauthentik/authentik/assets/1585352/5315f79d-9952-496a-b525-9981884154fb\">\r\n\r\n\r\n\r\n\n", "before_files": [{"content": "\"\"\"Events API Views\"\"\"\nfrom datetime import timedelta\nfrom json import loads\n\nimport django_filters\nfrom django.db.models.aggregates import Count\nfrom django.db.models.fields.json import KeyTextTransform\nfrom django.db.models.functions import ExtractDay\nfrom drf_spectacular.types import OpenApiTypes\nfrom drf_spectacular.utils import OpenApiParameter, extend_schema\nfrom guardian.shortcuts import get_objects_for_user\nfrom rest_framework.decorators import action\nfrom rest_framework.fields import DictField, IntegerField\nfrom rest_framework.request import Request\nfrom rest_framework.response import Response\nfrom rest_framework.serializers import ModelSerializer\nfrom rest_framework.viewsets import ModelViewSet\n\nfrom authentik.admin.api.metrics import CoordinateSerializer\nfrom authentik.core.api.utils import PassiveSerializer, TypeCreateSerializer\nfrom authentik.events.models import Event, EventAction\n\n\nclass EventSerializer(ModelSerializer):\n    \"\"\"Event Serializer\"\"\"\n\n    class Meta:\n        model = Event\n        fields = [\n            \"pk\",\n            \"user\",\n            \"action\",\n            \"app\",\n            \"context\",\n            \"client_ip\",\n            \"created\",\n            \"expires\",\n            \"tenant\",\n        ]\n\n\nclass EventTopPerUserSerializer(PassiveSerializer):\n    \"\"\"Response object of Event's top_per_user\"\"\"\n\n    application = DictField()\n    counted_events = IntegerField()\n    unique_users = IntegerField()\n\n\nclass EventsFilter(django_filters.FilterSet):\n    \"\"\"Filter for events\"\"\"\n\n    username = django_filters.CharFilter(\n        field_name=\"user\", lookup_expr=\"username\", label=\"Username\"\n    )\n    context_model_pk = django_filters.CharFilter(\n        field_name=\"context\",\n        lookup_expr=\"model__pk\",\n        label=\"Context Model Primary Key\",\n        method=\"filter_context_model_pk\",\n    )\n    context_model_name = django_filters.CharFilter(\n        field_name=\"context\",\n        lookup_expr=\"model__model_name\",\n        label=\"Context Model Name\",\n    )\n    context_model_app = django_filters.CharFilter(\n        field_name=\"context\", lookup_expr=\"model__app\", label=\"Context Model App\"\n    )\n    context_authorized_app = django_filters.CharFilter(\n        field_name=\"context\",\n        lookup_expr=\"authorized_application__pk\",\n        label=\"Context Authorized application\",\n    )\n    action = django_filters.CharFilter(\n        field_name=\"action\",\n        lookup_expr=\"icontains\",\n    )\n    tenant_name = django_filters.CharFilter(\n        field_name=\"tenant\",\n        lookup_expr=\"name\",\n        label=\"Tenant name\",\n    )\n\n    def filter_context_model_pk(self, queryset, name, value):\n        \"\"\"Because we store the PK as UUID.hex,\n        we need to remove the dashes that a client may send. We can't use a\n        UUIDField for this, as some models might not have a UUID PK\"\"\"\n        value = str(value).replace(\"-\", \"\")\n        return queryset.filter(context__model__pk=value)\n\n    class Meta:\n        model = Event\n        fields = [\"action\", \"client_ip\", \"username\"]\n\n\nclass EventViewSet(ModelViewSet):\n    \"\"\"Event Read-Only Viewset\"\"\"\n\n    queryset = Event.objects.all()\n    serializer_class = EventSerializer\n    ordering = [\"-created\"]\n    search_fields = [\n        \"event_uuid\",\n        \"user\",\n        \"action\",\n        \"app\",\n        \"context\",\n        \"client_ip\",\n    ]\n    filterset_class = EventsFilter\n\n    @extend_schema(\n        methods=[\"GET\"],\n        responses={200: EventTopPerUserSerializer(many=True)},\n        filters=[],\n        parameters=[\n            OpenApiParameter(\n                \"action\",\n                type=OpenApiTypes.STR,\n                location=OpenApiParameter.QUERY,\n                required=False,\n            ),\n            OpenApiParameter(\n                \"top_n\",\n                type=OpenApiTypes.INT,\n                location=OpenApiParameter.QUERY,\n                required=False,\n            ),\n        ],\n    )\n    @action(detail=False, methods=[\"GET\"], pagination_class=None)\n    def top_per_user(self, request: Request):\n        \"\"\"Get the top_n events grouped by user count\"\"\"\n        filtered_action = request.query_params.get(\"action\", EventAction.LOGIN)\n        top_n = int(request.query_params.get(\"top_n\", \"15\"))\n        return Response(\n            get_objects_for_user(request.user, \"authentik_events.view_event\")\n            .filter(action=filtered_action)\n            .exclude(context__authorized_application=None)\n            .annotate(application=KeyTextTransform(\"authorized_application\", \"context\"))\n            .annotate(user_pk=KeyTextTransform(\"pk\", \"user\"))\n            .values(\"application\")\n            .annotate(counted_events=Count(\"application\"))\n            .annotate(unique_users=Count(\"user_pk\", distinct=True))\n            .values(\"unique_users\", \"application\", \"counted_events\")\n            .order_by(\"-counted_events\")[:top_n]\n        )\n\n    @extend_schema(\n        methods=[\"GET\"],\n        responses={200: CoordinateSerializer(many=True)},\n        filters=[],\n        parameters=[\n            OpenApiParameter(\n                \"action\",\n                type=OpenApiTypes.STR,\n                location=OpenApiParameter.QUERY,\n                required=False,\n            ),\n            OpenApiParameter(\n                \"query\",\n                type=OpenApiTypes.STR,\n                location=OpenApiParameter.QUERY,\n                required=False,\n            ),\n        ],\n    )\n    @action(detail=False, methods=[\"GET\"], pagination_class=None)\n    def per_month(self, request: Request):\n        \"\"\"Get the count of events per month\"\"\"\n        filtered_action = request.query_params.get(\"action\", EventAction.LOGIN)\n        try:\n            query = loads(request.query_params.get(\"query\", \"{}\"))\n        except ValueError:\n            return Response(status=400)\n        return Response(\n            get_objects_for_user(request.user, \"authentik_events.view_event\")\n            .filter(action=filtered_action)\n            .filter(**query)\n            .get_events_per(timedelta(weeks=4), ExtractDay, 30)\n        )\n\n    @extend_schema(responses={200: TypeCreateSerializer(many=True)})\n    @action(detail=False, pagination_class=None, filter_backends=[])\n    def actions(self, request: Request) -> Response:\n        \"\"\"Get all actions\"\"\"\n        data = []\n        for value, name in EventAction.choices:\n            data.append({\"name\": name, \"description\": \"\", \"component\": value, \"model_name\": \"\"})\n        return Response(TypeCreateSerializer(data, many=True).data)\n", "path": "authentik/events/api/events.py"}], "after_files": [{"content": "\"\"\"Events API Views\"\"\"\nfrom datetime import timedelta\nfrom json import loads\n\nimport django_filters\nfrom django.db.models.aggregates import Count\nfrom django.db.models.fields.json import KeyTextTransform, KeyTransform\nfrom django.db.models.functions import ExtractDay\nfrom drf_spectacular.types import OpenApiTypes\nfrom drf_spectacular.utils import OpenApiParameter, extend_schema\nfrom guardian.shortcuts import get_objects_for_user\nfrom rest_framework.decorators import action\nfrom rest_framework.fields import DictField, IntegerField\nfrom rest_framework.request import Request\nfrom rest_framework.response import Response\nfrom rest_framework.serializers import ModelSerializer\nfrom rest_framework.viewsets import ModelViewSet\n\nfrom authentik.admin.api.metrics import CoordinateSerializer\nfrom authentik.core.api.utils import PassiveSerializer, TypeCreateSerializer\nfrom authentik.events.models import Event, EventAction\n\n\nclass EventSerializer(ModelSerializer):\n    \"\"\"Event Serializer\"\"\"\n\n    class Meta:\n        model = Event\n        fields = [\n            \"pk\",\n            \"user\",\n            \"action\",\n            \"app\",\n            \"context\",\n            \"client_ip\",\n            \"created\",\n            \"expires\",\n            \"tenant\",\n        ]\n\n\nclass EventTopPerUserSerializer(PassiveSerializer):\n    \"\"\"Response object of Event's top_per_user\"\"\"\n\n    application = DictField()\n    counted_events = IntegerField()\n    unique_users = IntegerField()\n\n\nclass EventsFilter(django_filters.FilterSet):\n    \"\"\"Filter for events\"\"\"\n\n    username = django_filters.CharFilter(\n        field_name=\"user\", lookup_expr=\"username\", label=\"Username\"\n    )\n    context_model_pk = django_filters.CharFilter(\n        field_name=\"context\",\n        lookup_expr=\"model__pk\",\n        label=\"Context Model Primary Key\",\n        method=\"filter_context_model_pk\",\n    )\n    context_model_name = django_filters.CharFilter(\n        field_name=\"context\",\n        lookup_expr=\"model__model_name\",\n        label=\"Context Model Name\",\n    )\n    context_model_app = django_filters.CharFilter(\n        field_name=\"context\", lookup_expr=\"model__app\", label=\"Context Model App\"\n    )\n    context_authorized_app = django_filters.CharFilter(\n        field_name=\"context\",\n        lookup_expr=\"authorized_application__pk\",\n        label=\"Context Authorized application\",\n    )\n    action = django_filters.CharFilter(\n        field_name=\"action\",\n        lookup_expr=\"icontains\",\n    )\n    tenant_name = django_filters.CharFilter(\n        field_name=\"tenant\",\n        lookup_expr=\"name\",\n        label=\"Tenant name\",\n    )\n\n    def filter_context_model_pk(self, queryset, name, value):\n        \"\"\"Because we store the PK as UUID.hex,\n        we need to remove the dashes that a client may send. We can't use a\n        UUIDField for this, as some models might not have a UUID PK\"\"\"\n        value = str(value).replace(\"-\", \"\")\n        return queryset.filter(context__model__pk=value)\n\n    class Meta:\n        model = Event\n        fields = [\"action\", \"client_ip\", \"username\"]\n\n\nclass EventViewSet(ModelViewSet):\n    \"\"\"Event Read-Only Viewset\"\"\"\n\n    queryset = Event.objects.all()\n    serializer_class = EventSerializer\n    ordering = [\"-created\"]\n    search_fields = [\n        \"event_uuid\",\n        \"user\",\n        \"action\",\n        \"app\",\n        \"context\",\n        \"client_ip\",\n    ]\n    filterset_class = EventsFilter\n\n    @extend_schema(\n        methods=[\"GET\"],\n        responses={200: EventTopPerUserSerializer(many=True)},\n        filters=[],\n        parameters=[\n            OpenApiParameter(\n                \"action\",\n                type=OpenApiTypes.STR,\n                location=OpenApiParameter.QUERY,\n                required=False,\n            ),\n            OpenApiParameter(\n                \"top_n\",\n                type=OpenApiTypes.INT,\n                location=OpenApiParameter.QUERY,\n                required=False,\n            ),\n        ],\n    )\n    @action(detail=False, methods=[\"GET\"], pagination_class=None)\n    def top_per_user(self, request: Request):\n        \"\"\"Get the top_n events grouped by user count\"\"\"\n        filtered_action = request.query_params.get(\"action\", EventAction.LOGIN)\n        top_n = int(request.query_params.get(\"top_n\", \"15\"))\n        events = (\n            get_objects_for_user(request.user, \"authentik_events.view_event\")\n            .filter(action=filtered_action)\n            .exclude(context__authorized_application=None)\n            .annotate(application=KeyTransform(\"authorized_application\", \"context\"))\n            .annotate(user_pk=KeyTextTransform(\"pk\", \"user\"))\n            .values(\"application\")\n            .annotate(counted_events=Count(\"application\"))\n            .annotate(unique_users=Count(\"user_pk\", distinct=True))\n            .values(\"unique_users\", \"application\", \"counted_events\")\n            .order_by(\"-counted_events\")[:top_n]\n        )\n        return Response(EventTopPerUserSerializer(instance=events, many=True).data)\n\n    @extend_schema(\n        methods=[\"GET\"],\n        responses={200: CoordinateSerializer(many=True)},\n        filters=[],\n        parameters=[\n            OpenApiParameter(\n                \"action\",\n                type=OpenApiTypes.STR,\n                location=OpenApiParameter.QUERY,\n                required=False,\n            ),\n            OpenApiParameter(\n                \"query\",\n                type=OpenApiTypes.STR,\n                location=OpenApiParameter.QUERY,\n                required=False,\n            ),\n        ],\n    )\n    @action(detail=False, methods=[\"GET\"], pagination_class=None)\n    def per_month(self, request: Request):\n        \"\"\"Get the count of events per month\"\"\"\n        filtered_action = request.query_params.get(\"action\", EventAction.LOGIN)\n        try:\n            query = loads(request.query_params.get(\"query\", \"{}\"))\n        except ValueError:\n            return Response(status=400)\n        return Response(\n            get_objects_for_user(request.user, \"authentik_events.view_event\")\n            .filter(action=filtered_action)\n            .filter(**query)\n            .get_events_per(timedelta(weeks=4), ExtractDay, 30)\n        )\n\n    @extend_schema(responses={200: TypeCreateSerializer(many=True)})\n    @action(detail=False, pagination_class=None, filter_backends=[])\n    def actions(self, request: Request) -> Response:\n        \"\"\"Get all actions\"\"\"\n        data = []\n        for value, name in EventAction.choices:\n            data.append({\"name\": name, \"description\": \"\", \"component\": value, \"model_name\": \"\"})\n        return Response(TypeCreateSerializer(data, many=True).data)\n", "path": "authentik/events/api/events.py"}]}