Spaces:
Sleeping
Sleeping
File size: 2,036 Bytes
857d4f5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | from app.db.supabase_client import get_supabase_client
CACHE_KUFUR_DICT_TR = {}
CACHE_KUFUR_DICT_EN = {}
def load_blacklist_to_ram():
"""Supabase limitlerini (1000 satır) aşan sayfalama destekli loader."""
global CACHE_KUFUR_DICT_TR, CACHE_KUFUR_DICT_EN
temp_tr = {}
temp_en = {}
supabase = get_supabase_client()
if supabase is None:
print("⚠️ Supabase bağlantısı yok!")
return
try:
print("🌐 Supabase'den tüm liste çekiliyor...")
all_rows = []
start = 0
page_size = 1000
while True:
response = (
supabase.table("blacklist")
.select("word, language, category")
.range(start, start + page_size - 1)
.execute()
)
data = response.data or []
all_rows.extend(data)
if len(data) < page_size:
break
start += page_size
print(f"📊 Toplam çekilen satır: {len(all_rows)}")
found_langs = set()
for row in all_rows:
lang_raw = str(row.get("language", "")).lower().strip()
word = str(row.get("word", "")).lower().strip()
cat = str(row.get("category", "insult")).lower().strip() or "insult"
if not word:
continue
found_langs.add(lang_raw)
if lang_raw == "tr":
temp_tr[word] = cat
elif lang_raw == "en":
temp_en[word] = cat
CACHE_KUFUR_DICT_TR = temp_tr
CACHE_KUFUR_DICT_EN = temp_en
print(f"🔍 Veritabanındaki diller: {found_langs}")
print(f"✅ RAM Hazır: {len(temp_tr)} TR, {len(temp_en)} EN kelime.")
except Exception as exc:
print(f"❌ Cache Hatası: {exc}")
def get_blacklist_for_language(language: str):
return CACHE_KUFUR_DICT_TR if language == "tr" else CACHE_KUFUR_DICT_EN
def get_cache_counts():
return len(CACHE_KUFUR_DICT_TR), len(CACHE_KUFUR_DICT_EN)
|