Skip to content

Eshan#15

Merged
eshanhasitha merged 2 commits into
mainfrom
eshan
Jun 3, 2026
Merged

Eshan#15
eshanhasitha merged 2 commits into
mainfrom
eshan

Conversation

@eshanhasitha

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings June 3, 2026 19:44
@netlify

netlify Bot commented Jun 3, 2026

Copy link
Copy Markdown

Deploy Preview for gpacal-cis failed.

Name Link
🔨 Latest commit afb3ded
🔍 Latest deploy log https://app.netlify.com/projects/gpacal-cis/deploys/6a208422e8c5f60008f788dd

@eshanhasitha eshanhasitha merged commit 4c90b1e into main Jun 3, 2026
0 of 4 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 isGpa flags, 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 thread lib/parsePDF.ts
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 thread package.json
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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants