Lowercase cleanup improvement and added more words again.

This commit is contained in:
2025-07-22 20:03:39 +02:00
parent 38e9ed9b01
commit 45818046a2
3 changed files with 188 additions and 171 deletions

View File

@@ -114,11 +114,16 @@ def clean_stale_subreddits(active_subreddits):
log.info("\n--- Cleaning Stale Subreddits from Database ---")
conn = get_db_connection()
cursor = conn.cursor()
# Convert the list of active subreddits from the config file to a lowercase set for fast,
# case-insensitive lookups.
active_subreddits_lower = {sub.lower() for sub in active_subreddits}
cursor.execute("SELECT id, name FROM subreddits")
db_subreddits = cursor.fetchall()
stale_sub_ids = []
for sub in db_subreddits:
if sub['name'] not in active_subreddits:
if sub['name'] not in active_subreddits_lower:
log.info(f"Found stale subreddit to remove: r/{sub['name']}")
stale_sub_ids.append(sub['id'])
if not stale_sub_ids: