Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions pydis_site/apps/api/models/bot/metricity.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@

BLOCK_INTERVAL = 10 * 60 # 10 minute blocks

EXCLUDE_CHANNELS = (
# This needs to be a list due to psycopg3 type adaptions.
EXCLUDE_CHANNELS = [
"267659945086812160", # Bot commands
"607247579608121354" # SeasonalBot commands
)
]


class NotFoundError(Exception):
Expand Down Expand Up @@ -48,7 +49,7 @@ def total_messages(self, user_id: str) -> int:
WHERE
author_id = '%s'
AND NOT is_deleted
AND channel_id NOT IN %s
AND channel_id != ANY(%s)
""",
[user_id, EXCLUDE_CHANNELS]
)
Expand Down Expand Up @@ -76,7 +77,7 @@ def total_message_blocks(self, user_id: str) -> int:
WHERE
author_id='%s'
AND NOT is_deleted
AND channel_id NOT IN %s
AND channel_id != ANY(%s)
GROUP BY interval
) block_query;
""",
Expand Down Expand Up @@ -144,13 +145,13 @@ def total_messages_in_past_n_days(
author_id, COUNT(*)
FROM messages
WHERE
author_id IN %s
author_id = ANY(%s)
AND NOT is_deleted
AND channel_id NOT IN %s
AND channel_id != ANY(%s)
AND created_at > now() - interval '%s days'
GROUP BY author_id
""",
[tuple(user_ids), EXCLUDE_CHANNELS, days]
[user_ids, EXCLUDE_CHANNELS, days]
)
values = self.cursor.fetchall()

Expand Down