Refactor Discord member statistics handling and remove unused components

- Removed the `guild_member_stats` table and related logic from the database and models, as well as the associated webapp routes and templates.
- Cleaned up the Discord bot initialization by eliminating unused imports and functions related to member statistics.
- Updated logging configuration in `run-web.py` to streamline the startup process and improve thread management.
This commit is contained in:
2026-03-25 23:13:14 +01:00
parent b51430e2b2
commit ec296dd226
12 changed files with 10 additions and 662 deletions
+7 -27
View File
@@ -2,7 +2,6 @@ import locale
import logging
import threading
import os
import time
from logging.handlers import RotatingFileHandler
from webapp import webapp
@@ -38,25 +37,9 @@ if __name__ == '__main__':
handlers.append(file_handler)
logging.basicConfig(level=logging.INFO, handlers=handlers)
# Éviter les doublons de lignes discord (ex. discord.http sans [thread] puis avec) :
# discord.py peut attacher des handlers avant basicConfig ; on ne garde que la propagation vers la racine.
for _name in (
'discord',
'discord.client',
'discord.http',
'discord.gateway',
'discord.state',
'discord.webhook',
):
_lg = logging.getLogger(_name)
_lg.handlers.clear()
_lg.propagate = True
# Calmer les logs verbeux de certaines libs si besoin
logging.getLogger('werkzeug').setLevel(logging.WARNING)
logging.getLogger('discord').setLevel(logging.WARNING)
# 429 : en-têtes X-RateLimit-* (voir discordbot/rate_limit_logging.py + doc Discord rate limits)
logging.getLogger('discord.ratelimit_headers').setLevel(logging.WARNING)
# Hook exceptions non-capturées (threads inclus)
def _log_uncaught(exc_type, exc, tb):
@@ -70,15 +53,12 @@ if __name__ == '__main__':
locale.setlocale(locale.LC_TIME, 'fr_FR.UTF-8')
t_discord = threading.Thread(target=start_discord_bot, name='discord-bot')
t_web = threading.Thread(target=start_server, name='web-server')
t_twitch = threading.Thread(target=start_twitch_bot, name='twitch-bot')
jobs = []
jobs.append(threading.Thread(target=start_discord_bot, name='discord-bot'))
jobs.append(threading.Thread(target=start_server, name='web-server'))
jobs.append(threading.Thread(target=start_twitch_bot, name='twitch-bot'))
# Démarrer Discord en premier : le 429 sur GET /users/@me est souvent un pic au login ;
# lancer Waitress + Twitch quelques secondes après évite la concurrence au tout début.
t_discord.start()
time.sleep(3)
t_web.start()
t_twitch.start()
for job in (t_discord, t_web, t_twitch):
for job in jobs:
job.start()
for job in jobs:
job.join()