aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps/api/models
diff options
context:
space:
mode:
authorGravatar Chris Lovering <[email protected]>2021-12-11 13:59:40 +0000
committerGravatar Chris Lovering <[email protected]>2021-12-11 13:59:40 +0000
commit953f232d47ff4e07baeaffa8add7912ff05d6457 (patch)
tree2b3334a0e2ecc981162899981b52f3abc6421cf0 /pydis_site/apps/api/models
parentMerge pull request #631 from Akarys42/patch-1 (diff)
Use new approx message count view
We have added a new view to metricity that will keep track of an approximate message count, updating every 10 seconds. By doing this, we avoid running a query against the whole message table every time we want to get a user's messages.
Diffstat (limited to 'pydis_site/apps/api/models')
-rw-r--r--pydis_site/apps/api/models/bot/metricity.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/pydis_site/apps/api/models/bot/metricity.py b/pydis_site/apps/api/models/bot/metricity.py
index 901f191a..52e946ac 100644
--- a/pydis_site/apps/api/models/bot/metricity.py
+++ b/pydis_site/apps/api/models/bot/metricity.py
@@ -46,14 +46,12 @@ class Metricity:
self.cursor.execute(
"""
SELECT
- COUNT(*)
- FROM messages
+ message_count
+ FROM user_has_approx_message_count
WHERE
author_id = '%s'
- AND NOT is_deleted
- AND channel_id NOT IN %s
""",
- [user_id, EXCLUDE_CHANNELS]
+ [user_id]
)
values = self.cursor.fetchone()