chore: update comments and documentation for clarity and consistency across various files

- Translated comments from Spanish to English in vite.config.ts, docker-compose.yml, attendance-risk.ts, analytics.ts, attendance.ts, attendees.ts, enums.ts, groups.ts, and onboarding.ts.
- Improved descriptions for better understanding of code functionality and purpose.
- Ensured uniformity in terminology and phrasing throughout the codebase.
This commit is contained in:
Jose Selesan
2026-10-01 16:06:54 -03:00
parent 01b35691df
commit 69275c37b4
100 changed files with 1121 additions and 1086 deletions

View File

@@ -21,11 +21,11 @@ import {
} from '../../lib/risk';
import { ANALYTICS_WINDOW_MS } from '../get-overview/use-case';
/* Cuántas clases se miran hacia atrás por alumno. Es el techo real del modelo:
los `class_sessions` no se crean solos, se materializan cuando alguien entra
a "clases de hoy", así que no tiene sentido traer años de filas. Con 20
clases alcanza para la racha, para la ventana de tendencia de 4+4 y para el
porcentaje de asistencia que muestra la tarjeta. */
/* How many classes we look back per attendee. That is the real ceiling of the
model: `class_sessions` are not created on their own, they get materialized
when someone opens "today's classes", so pulling years of rows makes no
sense. 20 classes is enough for the streak, for the 4+4 trend window and for
the attendance rate the card shows. */
const MEMBER_HISTORY_LIMIT = 20;
type GetGroupsRiskOverviewDeps = {
@@ -42,7 +42,7 @@ type GroupRow = {
id: string;
name: string;
capacity: number | null;
/** Los que todavía esperan cupo (`GroupWaitlistEntry` en PENDING). */
/** The ones still waiting for a spot (`GroupWaitlistEntry` in PENDING). */
_count: { waitlist: number };
};
type AttendeeRow = { id: string; groupId: string; fullName: string; createdAt: Date };
@@ -54,10 +54,10 @@ type AttendanceRow = {
classSession: { startsAt: Date };
};
// Resumen de semáforo de riesgo por grupo para la lista de grupos.
// Un grupo es HIGH si tiene al menos un alumno en riesgo alto, MEDIUM si
// alguno en riesgo moderado y NONE en caso contrario. Los contadores dicen el
// motivo (faltas seguidas o asistencia baja) para que la lista pueda nombrarlo.
// Risk status light summary per group for the group listing.
// A group is HIGH if it has at least one attendee at high risk, MEDIUM if
// any is at medium risk and NONE otherwise. The counters state the reason
// (consecutive absences or low attendance) so the listing can name it.
export class GetGroupsRiskOverview {
constructor(private readonly deps: GetGroupsRiskOverviewDeps = {}) {}
@@ -92,10 +92,10 @@ export class GetGroupsRiskOverview {
select: { id: true, groupId: true, startsAt: true },
orderBy: { startsAt: 'desc' },
}) as Promise<SessionRow[]>,
/* Sin filtro de fecha, como antes: la racha del semáforo cuenta sobre el
historial completo del alumno, no sobre la ventana mensual. Sin recorte
tampoco: el corte a las últimas 20 clases lo hace `memberSessions`,
sobre las clases del grupo y no sobre estas filas. */
/* No date filter, as before: the status light streak counts over the
attendee's full history, not over the monthly window. No cap either:
the cut to the last 20 classes is done by `memberSessions`, over the
group's classes and not over these rows. */
db.attendance.findMany({
where: { attendee: { groupId: { in: groupIds } } },
select: {
@@ -118,9 +118,10 @@ export class GetGroupsRiskOverview {
const streamByAttendee = groupAttendanceByAttendee(attendances);
const worstRiskByGroup = new Map<string, GroupRiskLevel>();
// Por qué hay riesgo, en la misma pasada: un miembro con racha de faltas
// cuenta en el primero y solo en ese; el segundo agrupa a los que no llegan
// a racha y aun así quedan por debajo del mínimo de asistencia.
// Why there is risk, computed in the same pass: a member with an absence
// streak counts in the first counter and only there; the second one
// groups the members that don't reach a streak and are still below the
// attendance minimum.
const absenceStreakCountByGroup = new Map<string, number>();
const lowAttendanceCountByGroup = new Map<string, number>();
@@ -169,14 +170,14 @@ export class GetGroupsRiskOverview {
}
/**
* El resumen por nivel que consumen la tarjeta del listado y la sección de
* seguimiento del Inicio. Sale de `getGroupAttendanceSummary`, la misma función
* de dominio que se prueba en `test/attendance-risk.test.ts`, para que la regla
* no tenga dos copias: una acá y otra en el cliente.
* The per-level summary consumed by the listing card and the Home follow-up
* section. It comes from `getGroupAttendanceSummary`, the same domain function
* that `test/attendance-risk.test.ts` exercises, so the rule doesn't have two
* copies: one here and another in the client.
*
* `libres` y `enEspera` salen de acá y no del conteo de `Attendee`: el resumen
* cuenta los miembros del grupo y la tarjeta necesita los lugares del cupo
* para pintar el indicador.
* `libres` and `enEspera` come from here and not from the `Attendee` count: the
* summary counts the group members and the card needs the capacity slots to
* paint the indicator.
*/
function buildSummaryFields(
group: GroupRow,
@@ -194,9 +195,9 @@ function buildSummaryFields(
.filter((attendee) => attendee.groupId === group.id)
.map((attendee) => {
const attendeeAttendances = attendanceByAttendee.get(attendee.id) ?? [];
// Si el alumno tiene asistencias previas a su fecha de alta en la BD (ej.
// creado hoy pero con clases pasadas registradas), su fecha efectiva de
// incorporación es la de la primera clase a la que se le tomó asistencia.
// If the attendee has attendances before their enrollment date in the
// DB (e.g. created today but with past classes already recorded), their
// effective join date is the first class they were marked for.
const earliestAttendance = attendeeAttendances.reduce<Date | null>(
(earliest, att) =>
!earliest || att.classSession.startsAt < earliest
@@ -257,18 +258,18 @@ function groupAttendanceByAttendee(rows: AttendanceRow[]): Map<string, Attendanc
return byAttendee;
}
/* El universo de clases es el del grupo, no el de las filas de `Attendance`.
La asistencia se carga alumno por alumno y solo cuando alguien la marca, así
que "esta clase pasó y no hay registro de este alumno" es un estado real y
frecuente, no una falta. Si la lista se armara desde las filas de asistencia
esas clases no existirían y la racha no se cortaría: dos faltas separadas por
una clase sin marcar se contarían como tres seguidas.
El dominio ya las trata como neutras (`status: null`), así que acá solo hay
que elegir bien el universo y dejar el criterio en un solo lado.
`sessions` viene de más reciente a más antigua, así que quedarse con las
primeras `MEMBER_HISTORY_LIMIT` es quedarse con las clases recientes. El
recorte va por alumno y no global para que un grupo con mucha historia no le
robe ventana a los grupos que se listan después. */
/* The universe of classes is the group's, not the `Attendance` rows'.
Attendance is recorded attendee by attendee and only when someone marks a
class, so "this class happened and this attendee has no record" is a real
and frequent state, not an absence. If the list were built from the
attendance rows those classes wouldn't exist and the streak wouldn't break:
two absences separated by an unmarked class would count as three in a row.
The domain already treats them as neutral (`status: null`), so all that is
left here is to pick the right universe and keep the criterion on one side.
`sessions` comes from most recent to oldest, so keeping the first
`MEMBER_HISTORY_LIMIT` keeps the recent classes. The cut is per attendee
and not global, so a group with a long history doesn't steal window from
the groups listed after it. */
function memberSessions(sessions: SessionRow[], attendances: AttendanceRow[]): MemberClassSession[] {
const statusBySession = new Map(attendances.map((row) => [row.classSessionId, row.status]));