refactor: rename students endpoints to /sync/students/{trigger,status}

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
parent 179e850a
......@@ -27,7 +27,7 @@ No Makefile/linter config present, no test suite — use plain `go` toolchain co
## Endpoints
- `GET /health` — checks Postgres and Mongo connectivity.
- `POST /sync/trigger` / `GET /sync/status` — students pipeline: run now / last run time, rows synced (created/updated/deleted breakdown), last error if any.
- `POST /sync/students/trigger` / `GET /sync/students/status` — students pipeline: run now / last run time, rows synced (created/updated/deleted breakdown), last error if any.
- `POST /sync/parents/trigger` / `GET /sync/parents/status` — same, for the parents pipeline.
## Postgres source contract
......
......@@ -13,8 +13,8 @@ Sincroniza estudiantes (con padres y planes de pago) y apoderados desde PostgreS
## Endpoints
- `GET /health` — verifica la conectividad con Postgres y Mongo.
- `POST /sync/trigger` — ejecuta un ciclo de sincronización de estudiantes de inmediato.
- `GET /sync/status` — última ejecución de sincronización de estudiantes, filas sincronizadas (desglose creado/actualizado/eliminado), último error si lo hay.
- `POST /sync/students/trigger` — ejecuta un ciclo de sincronización de estudiantes de inmediato.
- `GET /sync/students/status` — última ejecución de sincronización de estudiantes, filas sincronizadas (desglose creado/actualizado/eliminado), último error si lo hay.
- `POST /sync/parents/trigger` — ejecuta un ciclo de sincronización de apoderados de inmediato.
- `GET /sync/parents/status` — última ejecución de sincronización de apoderados, filas sincronizadas (desglose creado/actualizado/eliminado), último error si lo hay.
......
......@@ -57,14 +57,14 @@ func syncResultJSON(err error, result appsync.SyncResult) gin.H {
return resp
}
// Trigger responde POST /sync/trigger: corre una sincronización AHORA y
// Trigger responde POST /sync/students/trigger: corre una sincronización AHORA y
// devuelve cómo salió.
func (h *Handlers) Trigger(c *gin.Context) {
err := h.studentsSvc.Run(c.Request.Context())
c.JSON(http.StatusOK, syncResultJSON(err, h.studentsSvc.LastResult()))
}
// Status responde GET /sync/status: devuelve el resultado del último ciclo
// Status responde GET /sync/students/status: devuelve el resultado del último ciclo
// (sin correr uno nuevo), incluyendo el último error si lo hubo.
func (h *Handlers) Status(c *gin.Context) {
result := h.studentsSvc.LastResult()
......
......@@ -29,7 +29,7 @@ func NewRouter(studentsSvc *appsync.Service, pgPing, mongoPing func(context.Cont
// Registro de rutas: método HTTP + path -> función manejadora.
r.GET("/health", h.Health) // ¿están vivas Postgres y Mongo?
r.POST("/sync/trigger", h.Trigger) // forzar una sincronización ahora
r.GET("/sync/status", h.Status) // ver el resultado del último ciclo
r.POST("/sync/students/trigger", h.Trigger) // forzar una sincronización ahora
r.GET("/sync/students/status", h.Status) // ver el resultado del último ciclo
return r
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment