feat: una sola regla de riesgo y preinscripciones pendientes en Inicio

- Estadísticas ("Alumnos en riesgo") y el job de reenganche usan la misma
  regla de dominio que la lista de grupos e Inicio
  (summarizeMemberAttendance). El armado del historial por alumno vive en
  analytics/lib/member-attendance.ts y se borra el clasificador viejo
  (racha o asistencia mensual < 50%).
- El badge de alumnos en riesgo muestra el motivo real (faltas seguidas,
  días sin venir o asistencia en baja).
- GET /home devuelve pendingPreRegistrations por grupo (en la misma
  consulta de grupos) y "Para atender" las lista con link a la ficha en
  la pestaña Pendientes (?section=pending).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jose Selesan
2026-10-27 11:28:21 -03:00
parent b12ffdda37
commit e6d405a71e
17 changed files with 297 additions and 278 deletions

View File

@@ -100,7 +100,7 @@ describe('GET /groups-risk/overview', () => {
});
});
it('cuenta el motivo: faltas seguidas y asistencia baja, sin repetir alumnos', async () => {
it('cuenta el motivo: faltas seguidas o inactividad, sin repetir alumnos', async () => {
prismaFetchGroupFindMany([group('group-1', 'Funcional'), group('group-2', 'Yoga')]);
prismaFetchAttendeeFindMany([
attendee('a-1', 'group-1'),
@@ -113,6 +113,7 @@ describe('GET /groups-risk/overview', () => {
{ id: 's2', groupId: 'group-1', startsAt: at(2) },
{ id: 's3', groupId: 'group-1', startsAt: at(3) },
{ id: 's4', groupId: 'group-1', startsAt: at(4) },
{ id: 's7', groupId: 'group-1', startsAt: at(15) },
{ id: 's5', groupId: 'group-2', startsAt: at(1) },
{ id: 's6', groupId: 'group-2', startsAt: at(2) },
]);
@@ -121,11 +122,10 @@ describe('GET /groups-risk/overview', () => {
attendance('a-1', 's1', 'ABSENT', at(1)),
attendance('a-1', 's2', 'ABSENT', at(2)),
attendance('a-1', 's3', 'PRESENT', at(3)),
// No streak, but attends less than half of the month's classes.
attendance('a-2', 's1', 'PRESENT', at(1)),
attendance('a-2', 's2', 'ABSENT', at(2)),
attendance('a-2', 's3', 'ABSENT', at(3)),
attendance('a-2', 's4', 'ABSENT', at(4)),
// A single absence, but 14 days between their last presence and the
// class they missed (the ones in between have no record): inactivity.
attendance('a-2', 's1', 'ABSENT', at(1)),
attendance('a-2', 's7', 'PRESENT', at(15)),
// Ok.
attendance('a-3', 's1', 'PRESENT', at(1)),
attendance('a-3', 's2', 'PRESENT', at(2)),
@@ -144,7 +144,7 @@ describe('GET /groups-risk/overview', () => {
{
groupId: 'group-1',
groupName: 'Funcional',
riskLevel: 'MEDIUM',
riskLevel: 'HIGH',
absenceStreakCount: 1,
lowAttendanceCount: 1,
},