dockerfile y correccion de rutas

This commit is contained in:
2025-03-13 21:52:21 +01:00
parent 68f36c5785
commit cae8b3732d
2 changed files with 7 additions and 10 deletions

View File

@ -15,5 +15,5 @@ RUN chmod +x /app/auto.sh
RUN ls RUN ls
# Ejecuta el script auto.sh al iniciar el contenedor, luego ejecuta uvicorn # Ejecuta el script auto.sh al iniciar el contenedor, luego ejecuta uvicorn
CMD ["/bin/sh", "-c", "/app/auto.sh && uvicorn app.main:app --reload --host 0.0.0.0 --port 8000"] CMD ["/bin/sh", "-c", "uvicorn app.main:app --reload --host 0.0.0.0 --port 8000"]

View File

@ -134,24 +134,21 @@ def count_news_by_source_for_keyword_in_range(
formatted_results = {fuente: count for fuente, count in results} formatted_results = {fuente: count for fuente, count in results}
return {"count_by_source_keyword": formatted_results} return {"count_by_source_keyword": formatted_results}
@router.get("/news/titles/by-keyword/date") @router.get("/news/titles/by-keyword/date-range")
def get_titles_by_keyword_for_date( def get_titles_by_keyword_in_range(
keyword: str, keyword: str, fecha_inicio: datetime, fecha_fin: datetime, db: Session = Depends(get_db)
fecha: datetime, # Ahora solo recibes una fecha
db: Session = Depends(get_db)
): ):
# Convertir la fecha recibida a solo la parte de la fecha (sin hora)
fecha = fecha.date()
results = ( results = (
db.query(NewsItem.titulo) db.query(NewsItem.titulo)
.filter( .filter(
NewsItem.keyword == keyword, NewsItem.keyword == keyword,
NewsItem.fecha.date() == fecha # Comparar solo la fecha sin la hora NewsItem.fecha >= fecha_inicio,
NewsItem.fecha <= fecha_fin
) )
.all() .all()
) )
# Convertir resultados en una sola cadena separada por comas
titles = ", ".join([titulo[0] for titulo in results if titulo[0]]) titles = ", ".join([titulo[0] for titulo in results if titulo[0]])
return {"titles": titles} return {"titles": titles}