diff options
| author | 2022-11-13 15:03:51 +0000 | |
|---|---|---|
| committer | 2022-11-25 22:43:45 +0000 | |
| commit | 13b9e28848d03d1750b96bcbde3a6988ee429aa6 (patch) | |
| tree | e517cf872aa39e14f55e2b0bb7dd5122412fa0cf | |
| parent | Remove modlog ignore for help chanels (diff) | |
Use a redis cache to determine if a help session was answered
| -rw-r--r-- | bot/exts/help_channels/_caches.py | 4 | ||||
| -rw-r--r-- | bot/exts/help_channels/_stats.py | 8 |
2 files changed, 8 insertions, 4 deletions
diff --git a/bot/exts/help_channels/_caches.py b/bot/exts/help_channels/_caches.py index eb15b8560..5d98f99d3 100644 --- a/bot/exts/help_channels/_caches.py +++ b/bot/exts/help_channels/_caches.py @@ -8,3 +8,7 @@ help_dm = RedisCache(namespace="HelpChannels.help_dm") # serialise the set as a comma separated string to allow usage with redis # RedisCache[discord.TextChannel.id, str[set[discord.User.id]]] session_participants = RedisCache(namespace="HelpChannels.session_participants") + +# Stores posts that have had a non-claimant reply. +# Currently only used to determine whether the post was answered or not when collecting stats. +posts_with_non_claimant_messages = RedisCache(namespace="HelpChannels.posts_with_non_claimant_messages") diff --git a/bot/exts/help_channels/_stats.py b/bot/exts/help_channels/_stats.py index 6c05b4701..8ab93f19d 100644 --- a/bot/exts/help_channels/_stats.py +++ b/bot/exts/help_channels/_stats.py @@ -5,6 +5,7 @@ import discord import bot from bot import constants +from bot.exts.help_channels import _caches from bot.log import get_logger log = get_logger(__name__) @@ -37,8 +38,7 @@ async def report_complete_session(help_session_post: discord.Thread, closed_on: in_use_time = arrow.utcnow() - open_time bot.instance.stats.timing("help_forum.in_use_time", in_use_time) - if set(help_session_post.members)-{help_session_post.owner_id} == set(): - # Can't use len(help_session_post.members) as the claimant (owner) may have left the thread. - bot.instance.stats.incr("help_forum.sessions.unanswered") - else: + if await _caches.posts_with_non_claimant_messages.get(help_session_post.id): bot.instance.stats.incr("help_forum.sessions.answered") + else: + bot.instance.stats.incr("help_forum.sessions.unanswered") |