aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps/api/viewsets
diff options
context:
space:
mode:
authorGravatar Boris Muratov <[email protected]>2021-03-07 00:59:41 +0200
committerGravatar Boris Muratov <[email protected]>2021-03-07 00:59:41 +0200
commit4f9c088f6b0458eb0ebb52ef899cdfdc57f2c43c (patch)
treef1141fc618584ca9af31ef5e5ff50d6a8ef829b7 /pydis_site/apps/api/viewsets
parentUpdate Dockerfile (diff)
Add route to get a member's data for helper review
Added route for getting a user's join date, total messages, and top 3 channels by activity. This information will be used to auto-review nominees.
Diffstat (limited to 'pydis_site/apps/api/viewsets')
-rw-r--r--pydis_site/apps/api/viewsets/bot/user.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/pydis_site/apps/api/viewsets/bot/user.py b/pydis_site/apps/api/viewsets/bot/user.py
index 829e2694..5e1f8775 100644
--- a/pydis_site/apps/api/viewsets/bot/user.py
+++ b/pydis_site/apps/api/viewsets/bot/user.py
@@ -262,3 +262,18 @@ class UserViewSet(ModelViewSet):
except NotFound:
return Response(dict(detail="User not found in metricity"),
status=status.HTTP_404_NOT_FOUND)
+
+ @action(detail=True)
+ def metricity_review_data(self, request: Request, pk: str = None) -> Response:
+ """Request handler for metricity_review_data endpoint."""
+ user = self.get_object()
+
+ with Metricity() as metricity:
+ try:
+ data = metricity.user(user.id)
+ data["total_messages"] = metricity.total_messages(user.id)
+ data["top_channel_activity"] = metricity.top_channel_activity(user.id)
+ return Response(data, status=status.HTTP_200_OK)
+ except NotFound:
+ return Response(dict(detail="User not found in metricity"),
+ status=status.HTTP_404_NOT_FOUND)