Spaces:
Runtime error
Runtime error
Greg Claude Opus 4.7 (1M context) commited on
Commit ·
4aadf35
1
Parent(s): 0e087c3
feat(ta-01): show sex breakdown (M/F) in admin attendance counter
Browse files- RosterItem dataclass + AdminRosterItem TS interface gain `sex` field.
- AdminAttendancePage counter now shows "(M: N · F: N)" alongside Presentes.
- Teacher response unchanged (StudentCardResponse doesn't include sex).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
backend/app/services/attendance.py
CHANGED
|
@@ -26,6 +26,7 @@ class RosterItem:
|
|
| 26 |
lastname: str
|
| 27 |
card_id: Optional[str]
|
| 28 |
phone_number: Optional[str]
|
|
|
|
| 29 |
already_checked_in: bool
|
| 30 |
entrance_logged: bool
|
| 31 |
|
|
@@ -151,6 +152,7 @@ def list_section_roster(
|
|
| 151 |
lastname=s.lastname,
|
| 152 |
card_id=s.card_id,
|
| 153 |
phone_number=s.phone_number,
|
|
|
|
| 154 |
already_checked_in=s.id in checked_in_ids,
|
| 155 |
entrance_logged=s.id in entrance_logged_ids,
|
| 156 |
)
|
|
|
|
| 26 |
lastname: str
|
| 27 |
card_id: Optional[str]
|
| 28 |
phone_number: Optional[str]
|
| 29 |
+
sex: Optional[str]
|
| 30 |
already_checked_in: bool
|
| 31 |
entrance_logged: bool
|
| 32 |
|
|
|
|
| 152 |
lastname=s.lastname,
|
| 153 |
card_id=s.card_id,
|
| 154 |
phone_number=s.phone_number,
|
| 155 |
+
sex=s.sex,
|
| 156 |
already_checked_in=s.id in checked_in_ids,
|
| 157 |
entrance_logged=s.id in entrance_logged_ids,
|
| 158 |
)
|
frontend/src/pages/AdminAttendancePage.tsx
CHANGED
|
@@ -98,7 +98,10 @@ export default function AdminAttendancePage() {
|
|
| 98 |
return aEff.present ? 1 : -1; // absent first
|
| 99 |
});
|
| 100 |
|
| 101 |
-
const
|
|
|
|
|
|
|
|
|
|
| 102 |
const absentCount = roster.length - presentCount;
|
| 103 |
|
| 104 |
return (
|
|
@@ -160,9 +163,12 @@ export default function AdminAttendancePage() {
|
|
| 160 |
) : (
|
| 161 |
<>
|
| 162 |
{roster.length > 0 && (
|
| 163 |
-
<div className="rounded-lg bg-emerald-50 border border-emerald-200 px-4 py-2 text-sm font-medium text-emerald-900 inline-flex gap-3">
|
| 164 |
<span>✓ Presentes: {presentCount}</span>
|
| 165 |
-
<span
|
|
|
|
|
|
|
|
|
|
| 166 |
</div>
|
| 167 |
)}
|
| 168 |
|
|
|
|
| 98 |
return aEff.present ? 1 : -1; // absent first
|
| 99 |
});
|
| 100 |
|
| 101 |
+
const presentRoster = roster.filter((r) => getEffective(r).present);
|
| 102 |
+
const presentCount = presentRoster.length;
|
| 103 |
+
const presentM = presentRoster.filter((r) => r.sex === 'M').length;
|
| 104 |
+
const presentF = presentRoster.filter((r) => r.sex === 'F').length;
|
| 105 |
const absentCount = roster.length - presentCount;
|
| 106 |
|
| 107 |
return (
|
|
|
|
| 163 |
) : (
|
| 164 |
<>
|
| 165 |
{roster.length > 0 && (
|
| 166 |
+
<div className="rounded-lg bg-emerald-50 border border-emerald-200 px-4 py-2 text-sm font-medium text-emerald-900 inline-flex items-center gap-3 flex-wrap">
|
| 167 |
<span>✓ Presentes: {presentCount}</span>
|
| 168 |
+
<span className="text-emerald-700 text-xs">
|
| 169 |
+
(♂ M: {presentM} · ♀ F: {presentF})
|
| 170 |
+
</span>
|
| 171 |
+
<span className="border-l border-emerald-300 pl-3">Ausentes: {absentCount}</span>
|
| 172 |
</div>
|
| 173 |
)}
|
| 174 |
|
frontend/src/services/adminAttendanceService.ts
CHANGED
|
@@ -7,6 +7,7 @@ export interface AdminRosterItem {
|
|
| 7 |
lastname: string;
|
| 8 |
card_id: string | null;
|
| 9 |
phone_number: string | null;
|
|
|
|
| 10 |
already_checked_in: boolean;
|
| 11 |
entrance_logged: boolean;
|
| 12 |
}
|
|
|
|
| 7 |
lastname: string;
|
| 8 |
card_id: string | null;
|
| 9 |
phone_number: string | null;
|
| 10 |
+
sex: 'M' | 'F' | null;
|
| 11 |
already_checked_in: boolean;
|
| 12 |
entrance_logged: boolean;
|
| 13 |
}
|