@@ -49,6 +49,7 @@ All endpoints prefixed with `/api/v1`.
...
@@ -49,6 +49,7 @@ All endpoints prefixed with `/api/v1`.
- `POST /api/v1/sync/students/trigger` / `GET /api/v1/sync/students/status` — students pipeline: run now / last run time, rows synced (created/updated/deleted breakdown), last error if any.
- `POST /api/v1/sync/students/trigger` / `GET /api/v1/sync/students/status` — students pipeline: run now / last run time, rows synced (created/updated/deleted breakdown), last error if any.
- `POST /api/v1/sync/students_incremental/trigger` / `GET /api/v1/sync/students_incremental/status` — carga incremental de estudiantes: `postgres.LoadDataStudent` (= `StudentQuery` + `pp.to_update OR ma.to_update`) relee solo las personas/matrículas marcadas y, al terminar, `postgres.StudentMarker` resetea `persona.pe_persona.to_update` y `matricula.ma_matricula.to_update` a `false`. No reconcilia borrados.
- `POST /api/v1/sync/students_incremental/trigger` / `GET /api/v1/sync/students_incremental/status` — carga incremental de estudiantes: `postgres.LoadDataStudent` (= `StudentQuery` + `pp.to_update OR ma.to_update`) relee solo las personas/matrículas marcadas y, al terminar, `postgres.StudentMarker` resetea `persona.pe_persona.to_update` y `matricula.ma_matricula.to_update` a `false`. No reconcilia borrados.
- `POST /api/v1/sync/payment_plans_incremental/trigger` / `GET /api/v1/sync/payment_plans_incremental/status` — carga incremental de planes de pago: `postgres.LoadDataPaymentPlan` (= `PaymentPlanQuery` unido a `caja.ca_plan_de_pago_intranet` por `plan_de_pago_id` y filtrado por su `to_update`) relee solo los planes marcados y, al terminar, `postgres.PaymentPlanMarker` resetea `caja.ca_plan_de_pago_intranet.to_update` a `false` y estampa `sync_last_update = now()`. No reconcilia borrados.
- `POST /api/v1/sync/balotarios/trigger` / `GET /api/v1/sync/balotarios/status` — pipeline de balotarios (misma forma). La primera corrida tarda ~2 min, así que usar `curl -m 290`.
- `POST /api/v1/sync/balotarios/trigger` / `GET /api/v1/sync/balotarios/status` — pipeline de balotarios (misma forma). La primera corrida tarda ~2 min, así que usar `curl -m 290`.
...
@@ -59,7 +60,7 @@ All endpoints prefixed with `/api/v1`.
...
@@ -59,7 +60,7 @@ All endpoints prefixed with `/api/v1`.
Students: `internal/infrastructure/database/postgres.StudentQuery`, a raw SQL query (not a function) joining `matricula.ma_estudiante`/`persona.pe_persona`/`matricula.ma_matricula`/`caja.ca_plan_de_pago`, grouped per student, `payment_plans`/`payment_plans_current_year` built via `JSON_AGG(...) FILTER (...)` split on `periodo_academico_id = 14`. Read directly by `postgres.StudentReader` (`pgx` row scan, no JSON envelope) — one Mongo doc per row, requires numeric `enrollment_id`. `student_enrollment_photo_url` sale de un `LEFT JOIN LATERAL` sobre `matricula.ma_requisito` (requisito 2961, "Foto tamaño carné"): la URL pública de Drive más reciente entre todas las matrículas del alumno, `null` si no tiene. Suma ~5 s al ciclo porque `ma_requisito` está inflada y no tiene índice por `requisito_documento_id`.
Students: `internal/infrastructure/database/postgres.StudentQuery`, a raw SQL query (not a function) joining `matricula.ma_estudiante`/`persona.pe_persona`/`matricula.ma_matricula`/`caja.ca_plan_de_pago`, grouped per student, `payment_plans`/`payment_plans_current_year` built via `JSON_AGG(...) FILTER (...)` split on `periodo_academico_id = 14`. Read directly by `postgres.StudentReader` (`pgx` row scan, no JSON envelope) — one Mongo doc per row, requires numeric `enrollment_id`. `student_enrollment_photo_url` sale de un `LEFT JOIN LATERAL` sobre `matricula.ma_requisito` (requisito 2961, "Foto tamaño carné"): la URL pública de Drive más reciente entre todas las matrículas del alumno, `null` si no tiene. Suma ~5 s al ciclo porque `ma_requisito` está inflada y no tiene índice por `requisito_documento_id`.
Payment plans: `internal/infrastructure/database/postgres.PaymentPlanQuery`, one document per plan of payment. Read by `postgres.StudentReader (anida los planes de pago)`.
Payment plans: `internal/infrastructure/database/postgres.PaymentPlanQuery`, one document per plan of payment. Read by `postgres.StudentReader (anida los planes de pago)`. La carga incremental usa `postgres.LoadDataPaymentPlan` (= `PaymentPlanQuery` + `INNER JOIN caja.ca_plan_de_pago_intranet` por `plan_de_pago_id` y filtro `coalesce(to_update, false)`): esa tabla (`plan_de_pago_id`, `to_update`, `sync_last_update`) es la que marca qué planes re-sincronizar, y `postgres.PaymentPlanMarker` la resetea (`to_update = false`, `sync_last_update = now()`) al terminar.
Parents: `internal/infrastructure/database/postgres.ParentQuery`, joins `persona.pe_persona` with an aggregated subquery on `matricula.ma_estudiante_apoderado` (one row per parent/guardian, `students` embedded via `JSON_AGG(json_build_object('student_id', ...))`). Read by `postgres.ParentReader` into `entities.Parent` — collection `parents`, archive `deleted_parents`, `IDField` = `parent_id`, `StateID` = 3.
Parents: `internal/infrastructure/database/postgres.ParentQuery`, joins `persona.pe_persona` with an aggregated subquery on `matricula.ma_estudiante_apoderado` (one row per parent/guardian, `students` embedded via `JSON_AGG(json_build_object('student_id', ...))`). Read by `postgres.ParentReader` into `entities.Parent` — collection `parents`, archive `deleted_parents`, `IDField` = `parent_id`, `StateID` = 3.