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:
@@ -227,31 +227,6 @@ def _doAddColumnMigrations(cursor: Cursor):
|
||||
except Exception as e:
|
||||
logging.warning(f"Table webapp_page_permission: {e}")
|
||||
|
||||
if not _tableExists('guild_member_stats', cursor):
|
||||
try:
|
||||
cursor.execute("""
|
||||
CREATE TABLE guild_member_stats (
|
||||
guild_id VARCHAR(64) NOT NULL,
|
||||
user_id VARCHAR(64) NOT NULL,
|
||||
message_count INTEGER NOT NULL DEFAULT 0,
|
||||
voice_seconds INTEGER NOT NULL DEFAULT 0,
|
||||
updated_at DATETIME,
|
||||
PRIMARY KEY (guild_id, user_id)
|
||||
)
|
||||
""")
|
||||
logging.info("Table guild_member_stats créée")
|
||||
except Exception as e:
|
||||
logging.warning(f"Table guild_member_stats: {e}")
|
||||
|
||||
if _tableExists("webapp_page_permission", cursor):
|
||||
try:
|
||||
cursor.execute(
|
||||
"INSERT OR IGNORE INTO webapp_page_permission (page_key, min_level, write_level) VALUES ('discord_members', 1, 1)"
|
||||
)
|
||||
except Exception as e:
|
||||
logging.warning(f"Permission page discord_members: {e}")
|
||||
|
||||
|
||||
def _doSeedAuth(cursor: Cursor):
|
||||
"""Seed rôles par défaut et permissions des pages si vides."""
|
||||
from database.models import ROLE_ORDER
|
||||
@@ -294,7 +269,6 @@ def _doSeedAuth(cursor: Cursor):
|
||||
("freeloot", 1, 2),
|
||||
("patreon", 1, 2),
|
||||
("moderation", 1, 2),
|
||||
("discord_members", 1, 1),
|
||||
("users", 5, 5),
|
||||
("settings", 5, 5),
|
||||
]
|
||||
|
||||
@@ -260,12 +260,3 @@ class ModShoutboxMessage(db.Model):
|
||||
message = db.Column(db.String(500), nullable=False)
|
||||
created_at = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
|
||||
|
||||
|
||||
class GuildMemberStats(db.Model):
|
||||
__tablename__ = 'guild_member_stats'
|
||||
guild_id = db.Column(db.String(64), primary_key=True)
|
||||
user_id = db.Column(db.String(64), primary_key=True)
|
||||
message_count = db.Column(db.Integer, nullable=False, default=0)
|
||||
voice_seconds = db.Column(db.Integer, nullable=False, default=0)
|
||||
updated_at = db.Column(db.DateTime, nullable=True)
|
||||
|
||||
|
||||
@@ -99,15 +99,6 @@ CREATE TABLE IF NOT EXISTS `member_invites` (
|
||||
`join_date` DATETIME NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `guild_member_stats` (
|
||||
`guild_id` VARCHAR(64) NOT NULL,
|
||||
`user_id` VARCHAR(64) NOT NULL,
|
||||
`message_count` INTEGER NOT NULL DEFAULT 0,
|
||||
`voice_seconds` INTEGER NOT NULL DEFAULT 0,
|
||||
`updated_at` DATETIME,
|
||||
PRIMARY KEY (`guild_id`, `user_id`)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `twitch_link_filter` (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`enabled` BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
|
||||
Reference in New Issue
Block a user