-
Notifications
You must be signed in to change notification settings - Fork 23
Fix auth, validation, and dashboard stats bugs #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
af03d7a
f8d2eb9
edcb3d7
69c0ea0
dfdb956
1e58563
7b711cd
56377f0
6b0ca08
2ce79ff
bfa2dd9
99cecaf
5f38d94
b15a5c9
d086b09
f2a9d80
3db6529
918aa22
f33cc45
5386ecb
60f4cad
82ac82e
cfaa5e6
8aa5dab
0201d54
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -189,27 +189,39 @@ export function OverviewClient() { | |
| const [ | ||
| studentsRes, | ||
| assignmentsRes, | ||
| assignmentsActiveRes, | ||
| attendanceRes, | ||
| gradesRes, | ||
| announcementsRes, | ||
| ] = await Promise.all([ | ||
| fetch("/api/students?limit=5"), | ||
| fetch("/api/assignments"), | ||
| fetch("/api/assignments?status=active&limit=1"), | ||
| fetch("/api/attendance"), | ||
| fetch("/api/grades"), | ||
| fetch("/api/announcements?limit=5"), | ||
| ]); | ||
|
|
||
| const [students, assignmentsData, attendance, grades, announcements] = | ||
| await Promise.all([ | ||
| studentsRes.json(), | ||
| assignmentsRes.json(), | ||
| attendanceRes.json(), | ||
| gradesRes.json(), | ||
| announcementsRes.json(), | ||
| ]); | ||
| const [ | ||
| students, | ||
| assignmentsData, | ||
| assignmentsActiveData, | ||
| attendance, | ||
| grades, | ||
| announcements, | ||
| ] = await Promise.all([ | ||
| studentsRes.json(), | ||
| assignmentsRes.json(), | ||
| assignmentsActiveRes.json(), | ||
| attendanceRes.json(), | ||
| gradesRes.json(), | ||
| announcementsRes.json(), | ||
| ]); | ||
|
|
||
| const assignments = assignmentsData.assignments ?? assignmentsData; | ||
| const assignmentsTotal = assignmentsData.total ?? assignments.length; | ||
| const pendingAssignments = assignmentsActiveData.total ?? | ||
| (assignmentsActiveData.assignments ?? assignmentsActiveData ?? []).length; | ||
|
Comment on lines
198
to
+224
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LGTM on the count fix — but
Consider either fetching with 🔧 Suggested adjustment- fetch("/api/assignments"),
- fetch("/api/assignments?status=active&limit=1"),
+ fetch("/api/assignments?limit=100"),
+ fetch("/api/assignments?status=active&limit=100"),Then derive 🤖 Prompt for AI Agents |
||
|
|
||
| // ── Attendance ── | ||
| const dateMap: Record< | ||
|
|
@@ -316,13 +328,9 @@ export function OverviewClient() { | |
| .slice(0, 5); | ||
|
|
||
| setStats({ | ||
| totalStudents: students.students?.length ?? 0, | ||
| totalAssignments: Array.isArray(assignments) | ||
| ? assignments.length | ||
| : (assignments.length ?? 0), | ||
| pendingAssignments: assignments.filter( | ||
| (a: { status: string }) => a.status === "active", | ||
| ).length, | ||
| totalStudents: students.total ?? students.students?.length ?? 0, | ||
| totalAssignments: assignmentsTotal, | ||
| pendingAssignments, | ||
| attendancePct, | ||
| attendanceBreakdown: { | ||
| present: totalPresent, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty-term default + upsert can silently overwrite a prior record.
With
termdefaulted to"Term 1"and the upsert keyed on{teacherId, studentId, subject, term}, two submissions without a term for the same(student, subject)will collide and the second one will overwrite the first underTerm 1. If clients commonly omit the term (the client already defaultstermto"Term 1"inopenAdd, so this is usually fine, but direct API users may not), consider either:termexplicitly at the schema level (z.string().min(1)) and returning 400 if missing, orrawResult: true/includeResultMetadata: true) so clients can distinguish create from update.Minor: the response always returns
201 Createdeven when the upsert merely updates an existing document.🤖 Prompt for AI Agents