Merge pull request 'endpoint de status' (#14) from pre-dev into dev
All checks were successful
DEPLOY_MULTI_BRACH/pipeline/head This commit looks good
All checks were successful
DEPLOY_MULTI_BRACH/pipeline/head This commit looks good
Reviewed-on: #14
This commit was merged in pull request #14.
This commit is contained in:
@@ -1,6 +1,13 @@
|
|||||||
from django.db import connection
|
from django.db import connection
|
||||||
from apps.common.utils import clean_sql_string, clean_sql_int
|
from apps.common.utils import clean_sql_string, clean_sql_int
|
||||||
|
|
||||||
|
|
||||||
|
def get_status_action():
|
||||||
|
"""
|
||||||
|
Acción simple para comprobar que la lógica de la API responde.
|
||||||
|
"""
|
||||||
|
return {"status": "ok", "message": "API is running"}
|
||||||
|
|
||||||
def getData(params):
|
def getData(params):
|
||||||
"""
|
"""
|
||||||
Función estándar para obtener datos de promociones.
|
Función estándar para obtener datos de promociones.
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
from django.urls import path
|
from django.urls import path
|
||||||
from .views import get_promocion_view
|
from .views import get_promocion_view, status_view
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
# Capa 1: Definición del endpoint
|
# Capa 1: Definición del endpoint
|
||||||
path('obtener/', get_promocion_view, name='get_promocion'),
|
path('obtener/', get_promocion_view, name='get_promocion'),
|
||||||
|
path('status/', status_view, name='api_status'),
|
||||||
|
|
||||||
]
|
]
|
||||||
@@ -2,6 +2,10 @@ import logging
|
|||||||
from django.http import JsonResponse
|
from django.http import JsonResponse
|
||||||
from .actions import getData
|
from .actions import getData
|
||||||
|
|
||||||
|
from django.http import JsonResponse
|
||||||
|
from .actions import get_status_action
|
||||||
|
|
||||||
|
|
||||||
# Configuración del logger para rastrear la ejecución
|
# Configuración del logger para rastrear la ejecución
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -51,4 +55,19 @@ def get_promocion_view(request):
|
|||||||
return JsonResponse({
|
return JsonResponse({
|
||||||
'status': 'error',
|
'status': 'error',
|
||||||
'message': 'Error interno del servidor'
|
'message': 'Error interno del servidor'
|
||||||
}, status=500)
|
}, status=500)
|
||||||
|
|
||||||
|
# En views.py
|
||||||
|
def status_view(request):
|
||||||
|
# BLOQUE 1: Log de iniciación
|
||||||
|
logger.info("Iniciando petición de status...")
|
||||||
|
|
||||||
|
# BLOQUE 2: Limpieza y validación de datos (En este caso no hay datos de entrada)
|
||||||
|
data_cleaned = {}
|
||||||
|
|
||||||
|
# BLOQUE 3: Llamada a la acción
|
||||||
|
response_data = get_status_action()
|
||||||
|
|
||||||
|
# BLOQUE 4: Log de cierre y retorno
|
||||||
|
logger.info("Status enviado correctamente.")
|
||||||
|
return JsonResponse(response_data, status=200)
|
||||||
Reference in New Issue
Block a user