2026.06.04 frontend építés közben
This commit is contained in:
58
backend/app/scripts/init_mlm_parameters.py
Normal file
58
backend/app/scripts/init_mlm_parameters.py
Normal file
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
MLM és Gamification paraméterek inicializálása a system_parameters táblába.
|
||||
Futtatás: docker compose exec sf_api python3 /app/backend/scripts/init_mlm_parameters.py
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import sys
|
||||
import os
|
||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
from sqlalchemy import select
|
||||
|
||||
from app.models.system.parameter import SystemParameter
|
||||
from app.core.config import settings
|
||||
|
||||
async def init_parameters():
|
||||
engine = create_async_engine(settings.DATABASE_URL, echo=False)
|
||||
async_session = sessionmaker(engine, class_=AsyncSession, expire_on_commit=False)
|
||||
|
||||
async with async_session() as session:
|
||||
# MLM százalékok
|
||||
mlm_params = [
|
||||
("mlm_level1_percent", "10", "MLM L1 jutalék százalék (10%)", "global"),
|
||||
("mlm_level2_percent", "5", "MLM L2 jutalék százalék (5%)", "global"),
|
||||
("mlm_level3_percent", "3", "MLM L3 jutalék százalék (3%)", "global"),
|
||||
("gamification_p2p_invite_xp", "50", "XP pontok a meghívónak sikeres KYC után", "global"),
|
||||
]
|
||||
|
||||
for key, value, description, scope in mlm_params:
|
||||
existing = await session.execute(
|
||||
select(SystemParameter).where(SystemParameter.key == key)
|
||||
)
|
||||
if existing.scalar_one_or_none():
|
||||
print(f"✓ {key} már létezik, kihagyva.")
|
||||
continue
|
||||
|
||||
param = SystemParameter(
|
||||
key=key,
|
||||
value=value,
|
||||
description=description,
|
||||
scope=scope,
|
||||
data_type="integer" if key.endswith("_percent") else "integer",
|
||||
is_editable=True,
|
||||
is_visible=True,
|
||||
region_code=None,
|
||||
user_id=None,
|
||||
)
|
||||
session.add(param)
|
||||
print(f"✓ {key} = {value} beállítva.")
|
||||
|
||||
await session.commit()
|
||||
print("✅ MLM paraméterek sikeresen inicializálva.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(init_parameters())
|
||||
Reference in New Issue
Block a user