Estructura inicial funcional con documentación en el README.md de la FastAPI

This commit is contained in:
2026-09-25 11:20:50 -03:00
parent edc71742fa
commit 774e227642
2710 changed files with 1012769 additions and 0 deletions

37
app/models.py Normal file
View File

@@ -0,0 +1,37 @@
"""Tablas de la API: solo los logs de búsquedas y descargas.
Los archivos y su texto ya no están acá: los indexa FSCrawler en Elasticsearch.
"""
from datetime import datetime, timezone
from sqlalchemy import DateTime, Integer, String
from sqlalchemy.orm import Mapped, mapped_column
from app.database import Base
def ahora() -> datetime:
return datetime.now(timezone.utc)
class LogBusqueda(Base):
__tablename__ = "log_busquedas"
id: Mapped[int] = mapped_column(Integer, primary_key=True)
usuario: Mapped[str] = mapped_column(String(100), index=True)
criterio: Mapped[str] = mapped_column(String(50)) # ej. "cedula+nombre"
valor: Mapped[str] = mapped_column(String(300))
resultados: Mapped[int] = mapped_column(Integer, default=0)
ip: Mapped[str] = mapped_column(String(64), default="")
fecha: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=ahora, index=True)
class LogDescarga(Base):
__tablename__ = "log_descargas"
id: Mapped[int] = mapped_column(Integer, primary_key=True)
usuario: Mapped[str] = mapped_column(String(100), index=True)
documento_id: Mapped[str] = mapped_column(String(128), index=True) # _id en Elasticsearch
ruta_relativa: Mapped[str] = mapped_column(String(1000))
ip: Mapped[str] = mapped_column(String(64), default="")
fecha: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=ahora, index=True)