Skip to content

Commit 953f232

Browse files
committed
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.
1 parent 6b96f52 commit 953f232

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

pydis_site/apps/api/models/bot/metricity.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,12 @@ def total_messages(self, user_id: str) -> int:
4646
self.cursor.execute(
4747
"""
4848
SELECT
49-
COUNT(*)
50-
FROM messages
49+
message_count
50+
FROM user_has_approx_message_count
5151
WHERE
5252
author_id = '%s'
53-
AND NOT is_deleted
54-
AND channel_id NOT IN %s
5553
""",
56-
[user_id, EXCLUDE_CHANNELS]
54+
[user_id]
5755
)
5856
values = self.cursor.fetchone()
5957

0 commit comments

Comments
 (0)