Eshan#15
Merged
Merged
Conversation
❌ Deploy Preview for gpacal-cis failed.
|
There was a problem hiding this comment.
Pull request overview
This PR primarily addresses data correctness and traceability in the GPA portal by fixing semester mapping, properly handling Non-GPA subjects in calculations, and adding upload tracking (with deletion) for result-sheet imports. It also improves parts of the admin/student UI to better reflect live data.
Changes:
- Add several DB maintenance scripts (seed subjects, fix semester mapping, fix
isGpaflags, deduplicate subjects). - Track each results import via
pdf_uploads, link results to an upload, show recent uploads on the admin dashboard, and allow admins to delete an upload (cascading associated results). - Correct FGPA calculation for partially-complete years and exclude Non-GPA subjects from FGPA-related computations; broaden PDF parsing to support hyphenated subject codes.
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/seedSubjects.ts | New subject seeding script with corrected year/semester mapping. |
| scripts/fixSemesterData.ts | New script to remap subjects to correct semesters and delete unused semester rows. |
| scripts/fixIsGpa.ts | New script to force isGpa=false when creditPoints=0. |
| scripts/deduplicateSubjects.ts | New script to remove duplicate subjects and re-parent results. |
| package.json | Adds new DB utility scripts (but currently drops db:seed). |
| lib/schema.ts | Adds results.pdfUploadId FK to pdf_uploads (cascade delete). |
| lib/parsePDF.ts | Expands subject code parsing to support hyphenated codes. |
| lib/grades.ts | Fixes FGPA computation normalization across completed years. |
| components/admin/AdminSidebar.tsx | Switches admin nav links implementation (currently causes routing/compile issues). |
| app/student/dashboard/page.tsx | Forces fresh GPA fetches and adds a refresh header section. |
| app/student/change-password/page.tsx | Forces fresh auth check fetch (cache: "no-store"). |
| app/api/student/gpa/route.ts | Forces dynamic evaluation for GPA endpoint. |
| app/api/admin/uploads/[id]/route.ts | Adds DELETE route to remove an upload and cascade-delete linked results. |
| app/api/admin/subjects/route.ts | Forces dynamic evaluation; changes GET auth behavior; fixes creditPoints=0 validation. |
| app/api/admin/students/route.ts | Forces dynamic evaluation; excludes Non-GPA subjects from FGPA calc. |
| app/api/admin/students/[index]/route.ts | Forces dynamic evaluation for student detail endpoint. |
| app/api/admin/results/save/route.ts | Logs uploads, associates results with an upload, and adjusts repeat-pass handling for Non-GPA. |
| app/api/admin/dashboard/stats/route.ts | Forces dynamic evaluation; excludes Non-GPA from at-risk FGPA computation. |
| app/admin/upload/Step4Success.tsx | UI tweaks; adds “Go to Dashboard” action. |
| app/admin/upload/Step1SubjectDetails.tsx | Adds subject suggestions + improved form semantics for Non-GPA / 0-credit cases. |
| app/admin/upload/page.tsx | Integrates AdminSidebar and updates initial creditPoints sentinel. |
| app/admin/students/page.tsx | Forces fresh fetches and adds refresh control in header. |
| app/admin/students/[index]/page.tsx | Forces fresh fetch for student detail. |
| app/admin/dashboard/page.tsx | Adds refresh + delete actions for recent uploads and introduces confirmation dialog. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+83
to
+87
| const correct = getCorrectSemester(sub.subjectCode); | ||
| if (!correct) { | ||
| console.warn(`⚠️ Cannot determine semester for ${sub.subjectCode} — skipping`); | ||
| continue; | ||
| } |
| import "dotenv/config"; | ||
| import { db } from "@/lib/db"; | ||
| import { subjects, semesters } from "@/lib/schema"; | ||
| import { eq, and, notInArray } from "drizzle-orm"; |
| const Icon = link.icon; | ||
| return ( | ||
| <Link | ||
| <a |
| @@ -2,7 +2,6 @@ | |||
|
|
|||
| import { useState } from "react"; | |||
| import { usePathname, useRouter } from "next/navigation"; | |||
Comment on lines
93
to
97
| const subjectMatch = normalizedText.match(SUBJECT_HEADER_REGEX); | ||
| if (subjectMatch) { | ||
| subjectCodeFromHeader = subjectMatch[1].replace(/\s+/g, "").toUpperCase(); | ||
| subjectNameFromHeader = subjectMatch[2].trim(); | ||
| } else { |
Comment on lines
22
to
24
| export async function GET(request: NextRequest) { | ||
| const admin = getAdminFromRequest(request); | ||
| if (!admin) { | ||
| return NextResponse.json({ error: "Unauthorized" }, { status: 401 }); | ||
| } | ||
| // No admin verification needed for public subject lookup | ||
|
|
Comment on lines
+155
to
+160
| const fetchStats = async () => { | ||
| try { | ||
| const res = await fetch("/api/admin/dashboard/stats", { | ||
| cache: "no-store", | ||
| }); | ||
| if (!res.ok) throw new Error("Failed to fetch stats"); |
Comment on lines
+252
to
+257
| .update(pdfUploads) | ||
| .set({ | ||
| status: "completed", | ||
| processedCount: saved, | ||
| }) | ||
| .where(eq(pdfUploads.id, pdfUploadId)); |
Comment on lines
+14
to
+17
| "seed:subjects": "tsx scripts/seedSubjects.ts", | ||
| "db:fix": "tsx scripts/fixSemesterData.ts", | ||
| "db:dedup": "tsx scripts/deduplicateSubjects.ts", | ||
| "db:fixgpa": "tsx scripts/fixIsGpa.ts" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.