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:
@@ -185,7 +185,7 @@ export function AnalyticsView() {
|
||||
) : null}
|
||||
</div>
|
||||
<p className="mt-1 text-sm text-foreground/60">
|
||||
Alumnos con ausencias consecutivas o baja asistencia mensual.
|
||||
Alumnos con faltas seguidas, que dejaron de venir o cuya asistencia viene en baja.
|
||||
</p>
|
||||
|
||||
{atRisk.length === 0 ? (
|
||||
|
||||
@@ -39,11 +39,9 @@ export function AtRiskStudentCard({
|
||||
</p>
|
||||
</div>
|
||||
</button>
|
||||
{student.riskLevel === 'HIGH' ? (
|
||||
<Badge variant="danger">{student.consecutiveAbsences} faltas seguidas</Badge>
|
||||
) : (
|
||||
<Badge variant="warning">Baja asistencia</Badge>
|
||||
)}
|
||||
<Badge variant={student.riskLevel === 'HIGH' ? 'danger' : 'warning'}>
|
||||
{riskReason(student)}
|
||||
</Badge>
|
||||
</div>
|
||||
|
||||
<div className="mt-3 flex items-center gap-2 border-t border-border pt-3">
|
||||
@@ -99,4 +97,18 @@ export function AtRiskStudentCard({
|
||||
</div>
|
||||
</li>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const DAY_MS = 86_400_000
|
||||
|
||||
/* The same reasons the domain rule weighs, in its order: an absence streak,
|
||||
then the time without coming, and last the declining trend (the only thing
|
||||
left that can flag someone with neither). */
|
||||
function riskReason(student: StudentAtRiskDto): string {
|
||||
if (student.consecutiveAbsences >= 2) return `${student.consecutiveAbsences} faltas seguidas`
|
||||
if (student.riskLevel === 'HIGH' && student.lastAttendedAt) {
|
||||
const days = Math.floor((Date.now() - new Date(student.lastAttendedAt).getTime()) / DAY_MS)
|
||||
return `${days} días sin venir`
|
||||
}
|
||||
return 'Asistencia en baja'
|
||||
}
|
||||
|
||||
@@ -91,13 +91,22 @@ type GroupDetailContextValue = {
|
||||
|
||||
const GroupDetailContext = createContext<GroupDetailContextValue | null>(null)
|
||||
|
||||
export function GroupDetailProvider({ groupId, children }: { groupId: string; children: ReactNode }) {
|
||||
export function GroupDetailProvider({
|
||||
groupId,
|
||||
initialSection = 'members',
|
||||
children,
|
||||
}: {
|
||||
groupId: string
|
||||
/** Lets a link open the detail straight on Pendientes (Home's "Para atender"). */
|
||||
initialSection?: ListSection
|
||||
children: ReactNode
|
||||
}) {
|
||||
const queryClient = useQueryClient()
|
||||
const toast = useToast()
|
||||
const { user } = useAuth()
|
||||
|
||||
const [isInviteModalOpen, setIsInviteModalOpen] = useState(false)
|
||||
const [listSection, setListSectionState] = useState<ListSection>('members')
|
||||
const [listSection, setListSectionState] = useState<ListSection>(initialSection)
|
||||
const [attendeeToRemove, setAttendeeToRemove] = useState<AttendeeDto | null>(null)
|
||||
const [selectedWaitlistEntry, setSelectedWaitlistEntry] = useState<GroupWaitlistEntryDto | null>(null)
|
||||
const [selectedPreRegistration, setSelectedPreRegistration] = useState<GroupPreRegistrationDto | null>(null)
|
||||
|
||||
Reference in New Issue
Block a user