feat: rediseño de Grupos y pantalla "Requiere atención"
- Grupos: subtítulo con resumen (grupos · alumnos · lugares libres), sección "Requiere atención" con los 4 alumnos más urgentes y tarjetas con avatares (punteados por lugar libre en grupos chicos, superpuestos con "+N" en grandes; con alerta primero y anillo de gravedad). - Pantalla nueva /groups/attention: filtros Todos/Asistencia/Pagos, secciones Urgente y A vigilar, Contactar / Enviar recordatorio por wa.me y "Resuelto" persistente con update optimista. - FAB "Nuevo grupo" que se pliega al scrollear (respeta reduced motion); los toasts en mobile suben para no quedar debajo. - Alertas centralizadas en computeStudentAlerts (shared). La regla de asistencia pasa a: urgente = 3 seguidas o 4 de las últimas 6; a vigilar = 2 de las últimas 4 (sin inactividad por días ni tendencia). Cuotas: 1 vencida vigilar, 2+ urgente. - Backend: GET /attention y POST /attention/:attendeeId/resolve; tabla attendee_alert_resolutions (la alerta vuelve si cambia la firma). - Tokens de gravedad para claro y oscuro; se quita el indicador de pills. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -100,7 +100,7 @@ describe('GET /groups-risk/overview', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('cuenta el motivo: faltas seguidas o inactividad, sin repetir alumnos', async () => {
|
||||
it('cuenta el motivo: faltas seguidas o faltas sueltas, sin repetir alumnos', async () => {
|
||||
prismaFetchGroupFindMany([group('group-1', 'Funcional'), group('group-2', 'Yoga')]);
|
||||
prismaFetchAttendeeFindMany([
|
||||
attendee('a-1', 'group-1'),
|
||||
@@ -122,10 +122,13 @@ 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)),
|
||||
// A single absence, but 14 days between their last presence and the
|
||||
// class they missed (the ones in between have no record): inactivity.
|
||||
// No streak (they came to s2), but 4 of their last 5 classes missed:
|
||||
// high risk through the window, not through the streak.
|
||||
attendance('a-2', 's1', 'ABSENT', at(1)),
|
||||
attendance('a-2', 's7', 'PRESENT', at(15)),
|
||||
attendance('a-2', 's2', 'PRESENT', at(2)),
|
||||
attendance('a-2', 's3', 'ABSENT', at(3)),
|
||||
attendance('a-2', 's4', 'ABSENT', at(4)),
|
||||
attendance('a-2', 's7', 'ABSENT', at(15)),
|
||||
// Ok.
|
||||
attendance('a-3', 's1', 'PRESENT', at(1)),
|
||||
attendance('a-3', 's2', 'PRESENT', at(2)),
|
||||
@@ -268,8 +271,9 @@ it('una clase sin registro corta la racha: no son faltas seguidas', async () =>
|
||||
{ id: 's3', groupId: 'group-1', startsAt: at(3) },
|
||||
]);
|
||||
// Absence, unmarked class, absence. Reading only the `Attendance` rows this
|
||||
// would look like a streak of 2 and the group would land in attention; the
|
||||
// middle class happened and has no record, so the real streak is 1.
|
||||
// would look like a streak of 2; the middle class happened and has no
|
||||
// record, so the real streak is 1. The level is still attention, but because
|
||||
// of the short window (2 absences in the last marked classes), not the streak.
|
||||
prismaFetchAttendanceFindMany([
|
||||
attendance('a-1', 's1', 'ABSENT', at(1)),
|
||||
attendance('a-1', 's3', 'ABSENT', at(3)),
|
||||
@@ -280,13 +284,13 @@ it('una clase sin registro corta la racha: no son faltas seguidas', async () =>
|
||||
expect(res.status).toBe(200);
|
||||
const { items } = (await res.json()) as { items: Record<string, unknown>[] };
|
||||
expect(items[0].riesgoAlto).toBe(0);
|
||||
expect(items[0].atencion).toBe(0);
|
||||
expect(items[0].ok).toBe(1);
|
||||
expect(items[0].atencion).toBe(1);
|
||||
expect(items[0].absenceStreakCount).toBe(0);
|
||||
expect(items[0].urgentes).toEqual([
|
||||
{
|
||||
attendeeId: 'a-1',
|
||||
fullName: 'Sofía Díaz',
|
||||
level: 'ok',
|
||||
level: 'atencion',
|
||||
consecutiveAbsences: 1,
|
||||
daysSinceLastAttendance: 1,
|
||||
// Both marked classes were absences; the middle one does not go into the average.
|
||||
@@ -340,7 +344,8 @@ it('una clase sin registrar después de las faltas las borra: la racha mira hast
|
||||
// recent class (s1) is the one with no record. Since the streak is counted
|
||||
// from the end and "no record" is not an absence, there is no streak: the
|
||||
// asymmetry is there on purpose, because it is the same thing that already
|
||||
// happens with an excused class.
|
||||
// happens with an excused class. The two absences still fill the short
|
||||
// window, so the level is attention without a streak.
|
||||
prismaFetchAttendanceFindMany([
|
||||
attendance('a-1', 's2', 'ABSENT', at(2)),
|
||||
attendance('a-1', 's3', 'ABSENT', at(3)),
|
||||
@@ -350,14 +355,14 @@ it('una clase sin registrar después de las faltas las borra: la racha mira hast
|
||||
|
||||
expect(res.status).toBe(200);
|
||||
const { items } = (await res.json()) as { items: Record<string, unknown>[] };
|
||||
expect(items[0].atencion).toBe(0);
|
||||
expect(items[0].atencion).toBe(1);
|
||||
expect(items[0].riesgoAlto).toBe(0);
|
||||
expect(items[0].ok).toBe(1);
|
||||
expect(items[0].absenceStreakCount).toBe(0);
|
||||
expect(items[0].urgentes).toEqual([
|
||||
{
|
||||
attendeeId: 'a-1',
|
||||
fullName: 'Sofía Díaz',
|
||||
level: 'ok',
|
||||
level: 'atencion',
|
||||
consecutiveAbsences: 0,
|
||||
daysSinceLastAttendance: 1,
|
||||
attendanceRate: 0,
|
||||
|
||||
Reference in New Issue
Block a user