diff options
| author | 2021-11-23 13:00:11 +0100 | |
|---|---|---|
| committer | 2021-11-23 13:00:11 +0100 | |
| commit | d1a051e6aa7df063552d626318ba236de11661b4 (patch) | |
| tree | f7f0355bd539a9bdd9622c6de9877d0949fc3aeb /pydis_site/apps/api/viewsets | |
| parent | Merge pull request #625 from python-discord/filter-redirects (diff) | |
| parent | Add metricity test for users >1k messages (diff) | |
Merge pull request #627 from python-discord/don't-always-calc-activity-blocks
Don't always calc activity blocks
Diffstat (limited to 'pydis_site/apps/api/viewsets')
| -rw-r--r-- | pydis_site/apps/api/viewsets/bot/user.py | 8 | 
1 files changed, 7 insertions, 1 deletions
| diff --git a/pydis_site/apps/api/viewsets/bot/user.py b/pydis_site/apps/api/viewsets/bot/user.py index 22d13dc4..ed661323 100644 --- a/pydis_site/apps/api/viewsets/bot/user.py +++ b/pydis_site/apps/api/viewsets/bot/user.py @@ -271,9 +271,15 @@ class UserViewSet(ModelViewSet):          with Metricity() as metricity:              try:                  data = metricity.user(user.id) +                  data["total_messages"] = metricity.total_messages(user.id) +                if data["total_messages"] < 1000: +                    # Only calculate and return activity_blocks if the user has a small amount +                    # of messages, as calculating activity_blocks is expensive. +                    # 1000 message chosen as an arbitrarily large number. +                    data["activity_blocks"] = metricity.total_message_blocks(user.id) +                  data["voice_banned"] = voice_banned -                data["activity_blocks"] = metricity.total_message_blocks(user.id)                  return Response(data, status=status.HTTP_200_OK)              except NotFoundError:                  return Response(dict(detail="User not found in metricity"), | 
