feat: Initial commit for OnEver Drive centralized backup system with Windows PyQt6 agent and Proxmox LXC deployment
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
from typing import List, Optional
|
||||
from fastapi import APIRouter, Depends, Query
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from sqlalchemy import select, desc
|
||||
|
||||
from app.core.database import get_db
|
||||
from app.models.models import EventLog, User
|
||||
from app.schemas.schemas import EventLogResponse
|
||||
from app.api.deps import get_current_user
|
||||
|
||||
router = APIRouter(prefix="/events", tags=["Audit & Events"])
|
||||
|
||||
@router.get("", response_model=List[EventLogResponse])
|
||||
async def list_events(
|
||||
client_id: Optional[int] = None,
|
||||
job_id: Optional[int] = None,
|
||||
event_type: Optional[str] = None,
|
||||
limit: int = Query(50, le=200),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
current_user: User = Depends(get_current_user)
|
||||
):
|
||||
query = select(EventLog)
|
||||
if client_id:
|
||||
query = query.where(EventLog.client_id == client_id)
|
||||
if job_id:
|
||||
query = query.where(EventLog.job_id == job_id)
|
||||
if event_type:
|
||||
query = query.where(EventLog.event_type == event_type)
|
||||
|
||||
query = query.order_by(desc(EventLog.timestamp)).limit(limit)
|
||||
result = await db.execute(query)
|
||||
return result.scalars().all()
|
||||
Reference in New Issue
Block a user