frontend admin refakctorálás

This commit is contained in:
Roo
2026-07-08 08:03:57 +00:00
parent 07b59032ce
commit 2e0abc62a7
455 changed files with 14428 additions and 21651 deletions

View File

@@ -0,0 +1,62 @@
# /opt/docker/dev/service_finder/backend/app/scripts/seed_validation_rules.py
"""
Seed script for gamification.validation_rules table.
Inserts the base validation rules required by the P0 Architecture:
BOT_BASE_SCORE = 20 # Default trust score for robot-discovered entries
FIRST_ENTRY_SCORE = 40 # Score awarded for the first user entry
USER_CONFIRM_BASE = 20 # Base score per user confirmation vote
AUTO_APPROVE_THRESHOLD = 80 # Minimum validation_level to auto-promote
Usage:
docker exec -it sf_api python -m app.scripts.seed_validation_rules
"""
import asyncio
import logging
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent.parent))
from app.database import AsyncSessionLocal
from app.models.gamification.validation_rule import ValidationRule
from sqlalchemy import select
logging.basicConfig(level=logging.INFO, format='%(asctime)s [%(levelname)s] %(name)s: %(message)s')
logger = logging.getLogger("SeedValidationRules")
BASE_RULES = [
{"rule_key": "BOT_BASE_SCORE", "rule_value": 20, "description": "Default trust score for robot-discovered service entries"},
{"rule_key": "FIRST_ENTRY_SCORE", "rule_value": 40, "description": "Score awarded for the first user-submitted service entry"},
{"rule_key": "USER_CONFIRM_BASE", "rule_value": 20, "description": "Base score per user confirmation vote (level multiplier added)"},
{"rule_key": "AUTO_APPROVE_THRESHOLD", "rule_value": 80, "description": "Minimum validation_level required for auto-promotion to provider"},
]
async def seed():
async with AsyncSessionLocal() as db:
for rule_data in BASE_RULES:
# Check if rule already exists
stmt = select(ValidationRule).where(ValidationRule.rule_key == rule_data["rule_key"])
result = await db.execute(stmt)
existing = result.scalar_one_or_none()
if existing:
logger.info(f"Rule '{rule_data['rule_key']}' already exists (value={existing.rule_value}), skipping.")
continue
rule = ValidationRule(
rule_key=rule_data["rule_key"],
rule_value=rule_data["rule_value"],
description=rule_data["description"],
)
db.add(rule)
logger.info(f"Created rule '{rule_data['rule_key']}' = {rule_data['rule_value']}")
await db.commit()
logger.info("✅ Validation rules seeded successfully.")
if __name__ == "__main__":
asyncio.run(seed())