feat(api): add timezone support for group fetching and increase page size
feat(attendance): refactor attendance summary logic and update tests feat(analytics): extend GroupRiskSummary schema with absence and attendance counts feat(groups): enhance group schema with attendee and waitlist counts chore(skills): add frontend design skill with guidelines and license feat(attendee-detail): implement AttendeePhoneLine component for phone display feat(groups): create AttendanceBadge and CapacityIndicator components for group cards feat(groups): add card utility functions for attendance alerts and capacity summaries test(groups): implement tests for attendance alert and capacity summary logic
This commit is contained in:
@@ -86,8 +86,82 @@ describe('GET /groups-risk/overview', () => {
|
||||
expect(res.status).toBe(200);
|
||||
expect(await res.json()).toEqual({
|
||||
items: [
|
||||
{ groupId: 'group-1', groupName: 'Funcional', riskLevel: 'HIGH' },
|
||||
{ groupId: 'group-2', groupName: 'Yoga', riskLevel: 'NONE' },
|
||||
{
|
||||
groupId: 'group-1',
|
||||
groupName: 'Funcional',
|
||||
riskLevel: 'HIGH',
|
||||
absenceStreakCount: 1,
|
||||
lowAttendanceCount: 0,
|
||||
},
|
||||
{
|
||||
groupId: 'group-2',
|
||||
groupName: 'Yoga',
|
||||
riskLevel: 'NONE',
|
||||
absenceStreakCount: 0,
|
||||
lowAttendanceCount: 0,
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it('cuenta el motivo: faltas seguidas y asistencia baja, sin repetir alumnos', async () => {
|
||||
prismaFetchGroupFindMany([
|
||||
{ id: 'group-1', name: 'Funcional' },
|
||||
{ id: 'group-2', name: 'Yoga' },
|
||||
]);
|
||||
prismaFetchAttendeeFindMany([
|
||||
{ id: 'a-1', groupId: 'group-1' },
|
||||
{ id: 'a-2', groupId: 'group-1' },
|
||||
{ id: 'a-3', groupId: 'group-1' },
|
||||
{ id: 'b-1', groupId: 'group-2' },
|
||||
]);
|
||||
prismaFetchClassSessionFindMany([
|
||||
{ id: 's1', groupId: 'group-1', startsAt: at(-1) },
|
||||
{ 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: 's5', groupId: 'group-2', startsAt: at(-1) },
|
||||
{ id: 's6', groupId: 'group-2', startsAt: at(-2) },
|
||||
]);
|
||||
prismaFetchAttendanceFindMany([
|
||||
// Dos faltas seguidas: cuenta en el motivo de faltas.
|
||||
attendance('a-1', 'ABSENT', at(-1)),
|
||||
attendance('a-1', 'ABSENT', at(-2)),
|
||||
attendance('a-1', 'PRESENT', at(-3)),
|
||||
// Sin racha, pero asiste menos de la mitad de las clases del mes.
|
||||
attendance('a-2', 'PRESENT', at(-1)),
|
||||
attendance('a-2', 'ABSENT', at(-2)),
|
||||
attendance('a-2', 'ABSENT', at(-3)),
|
||||
attendance('a-2', 'ABSENT', at(-4)),
|
||||
// Al día.
|
||||
attendance('a-3', 'PRESENT', at(-1)),
|
||||
attendance('a-3', 'PRESENT', at(-2)),
|
||||
attendance('a-3', 'PRESENT', at(-3)),
|
||||
attendance('a-3', 'PRESENT', at(-4)),
|
||||
// Otra vez por racha, en el otro grupo.
|
||||
attendance('b-1', 'ABSENT', at(-1)),
|
||||
attendance('b-1', 'ABSENT', at(-2)),
|
||||
]);
|
||||
|
||||
const res = await makeApp({ id: userId }).request('/groups-risk/overview');
|
||||
|
||||
expect(res.status).toBe(200);
|
||||
expect(await res.json()).toEqual({
|
||||
items: [
|
||||
{
|
||||
groupId: 'group-1',
|
||||
groupName: 'Funcional',
|
||||
riskLevel: 'MEDIUM',
|
||||
absenceStreakCount: 1,
|
||||
lowAttendanceCount: 1,
|
||||
},
|
||||
{
|
||||
groupId: 'group-2',
|
||||
groupName: 'Yoga',
|
||||
riskLevel: 'MEDIUM',
|
||||
absenceStreakCount: 1,
|
||||
lowAttendanceCount: 0,
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user