Add guild_member_stats table and update permissions for Discord members

- Created a new table `guild_member_stats` to track message counts and voice activity for users in each guild.
- Updated the database schema and models to include the new table.
- Added a new permission entry for `discord_members` in the `webapp_page_permission` table.
- Enhanced the webapp to include links and settings for managing Discord member statistics.
This commit is contained in:
2026-03-25 22:52:32 +01:00
parent bb92c3dd92
commit 855c13c183
10 changed files with 535 additions and 2 deletions
+25
View File
@@ -227,6 +227,30 @@ 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."""
@@ -270,6 +294,7 @@ def _doSeedAuth(cursor: Cursor):
("freeloot", 1, 2),
("patreon", 1, 2),
("moderation", 1, 2),
("discord_members", 1, 1),
("users", 5, 5),
("settings", 5, 5),
]