refactor: remove commented sections and clean up code in various files
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
# api/routers/docit2mf_build.py
|
||||
|
||||
import logging
|
||||
from fastapi import APIRouter, HTTPException, Request
|
||||
from slowapi import Limiter
|
||||
|
||||
@@ -9,7 +9,6 @@ def validate_simple_docmf(request: SimpleValidationRequest):
|
||||
results = validate_simple_levels(request.levels)
|
||||
invalid = [r for r in results if not r["valid"]]
|
||||
|
||||
# Caso: un solo nivel
|
||||
if len(request.levels) == 1:
|
||||
if invalid:
|
||||
raise HTTPException(
|
||||
@@ -24,7 +23,6 @@ def validate_simple_docmf(request: SimpleValidationRequest):
|
||||
"details": results[0]
|
||||
}
|
||||
|
||||
# Caso: varios niveles
|
||||
if invalid:
|
||||
return {
|
||||
"message": "Validación completada.",
|
||||
|
||||
@@ -14,10 +14,6 @@ GOOGLE_CLIENT_SECRET = os.getenv("GOOGLE_CLIENT_SECRET")
|
||||
REDIRECT_URI = os.getenv("GOOGLE_REDIRECT_URI")
|
||||
SECRET_KEY = os.getenv("SECRET_KEY")
|
||||
|
||||
|
||||
# -----------------------------
|
||||
# 1. LOGIN → REDIRECCIÓN A GOOGLE
|
||||
# -----------------------------
|
||||
@router.get("/login")
|
||||
async def google_login():
|
||||
google_auth_url = (
|
||||
@@ -32,10 +28,6 @@ async def google_login():
|
||||
|
||||
return RedirectResponse(google_auth_url)
|
||||
|
||||
|
||||
# -----------------------------
|
||||
# 2. CALLBACK → GOOGLE DEVUELVE EL CODE
|
||||
# -----------------------------
|
||||
@router.get("/callback")
|
||||
async def google_callback(request: Request):
|
||||
|
||||
|
||||
@@ -10,10 +10,6 @@ from api.utils.security import get_current_user
|
||||
|
||||
router = APIRouter(prefix="/history", tags=["history"])
|
||||
|
||||
|
||||
# -----------------------------
|
||||
# 1. Añadir un elemento al historial
|
||||
# -----------------------------
|
||||
@router.post("/add")
|
||||
async def add_history_item(
|
||||
data: HistoryCreateRequest,
|
||||
@@ -39,10 +35,6 @@ async def add_history_item(
|
||||
"history_item_id": str(history_item_id),
|
||||
}
|
||||
|
||||
|
||||
# -----------------------------
|
||||
# 2. Eliminar un elemento del historial
|
||||
# -----------------------------
|
||||
@router.delete("/delete/{history_item_id}")
|
||||
async def delete_history_item(
|
||||
history_item_id: str,
|
||||
@@ -64,9 +56,6 @@ async def delete_history_item(
|
||||
return {"message": "Elemento eliminado del historial"}
|
||||
|
||||
|
||||
# -----------------------------
|
||||
# 3. Obtener todos los historiales de todos los usuarios (ordenados)
|
||||
# -----------------------------
|
||||
@router.get("/all")
|
||||
async def get_all_histories():
|
||||
users = await users_collection.find().to_list(None)
|
||||
@@ -90,7 +79,6 @@ async def get_all_histories():
|
||||
}
|
||||
})
|
||||
|
||||
# Ordenar por fecha
|
||||
all_histories_sorted = sorted(
|
||||
all_histories,
|
||||
key=lambda h: h["history_item"]["created_at"]
|
||||
@@ -98,10 +86,6 @@ async def get_all_histories():
|
||||
|
||||
return {"count": len(all_histories_sorted), "histories": all_histories_sorted}
|
||||
|
||||
|
||||
# -----------------------------
|
||||
# 4. Obtener historiales del usuario autenticado (ordenados)
|
||||
# -----------------------------
|
||||
@router.get("/user")
|
||||
async def get_user_histories(current_user: dict = Depends(get_current_user)):
|
||||
user_id = current_user["_id"]
|
||||
@@ -116,7 +100,6 @@ async def get_user_histories(current_user: dict = Depends(get_current_user)):
|
||||
|
||||
history = user.get("history", [])
|
||||
|
||||
# Ordenar por fecha
|
||||
history_sorted = sorted(history, key=lambda h: h["created_at"])
|
||||
|
||||
formatted_history = []
|
||||
|
||||
Reference in New Issue
Block a user