"""التحقق من سجل التنبيهات"""
import asyncio
from app.database import AsyncSessionLocal
from app.models.alert import AlertLog
from sqlalchemy import select

async def check():
    async with AsyncSessionLocal() as session:
        result = await session.execute(
            select(AlertLog).order_by(AlertLog.triggered_at.desc()).limit(5)
        )
        alerts = result.scalars().all()
        
        print("=" * 60)
        print("ALERT LOGS:")
        print("=" * 60)
        
        if not alerts:
            print("No alerts found")
        else:
            for a in alerts:
                print(f"ID: {a.id}")
                print(f"  Title: {a.title}")
                print(f"  Message: {a.message}")
                print(f"  Value: {a.reading_value}")
                print(f"  Severity: {a.severity}")
                print(f"  Resolved: {a.is_resolved}")
                print(f"  Time: {a.triggered_at}")
                print()

if __name__ == "__main__":
    asyncio.run(check())
