First commit
This commit is contained in:
23
app/api/mahasiswa/status/route.ts
Normal file
23
app/api/mahasiswa/status/route.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import db from '@/lib/db';
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
const query = `
|
||||
SELECT m.tahun_angkatan, s.status_kuliah, COUNT(*) AS jumlah
|
||||
FROM mahasiswa m
|
||||
JOIN status_mahasiswa s ON m.nim = s.nim
|
||||
WHERE s.status_kuliah IN ('Lulus', 'Cuti', 'Aktif', 'DO')
|
||||
GROUP BY m.tahun_angkatan, s.status_kuliah;
|
||||
`;
|
||||
|
||||
const [rows] = await db.query(query);
|
||||
return NextResponse.json(rows);
|
||||
} catch (error) {
|
||||
console.error('Error fetching status data:', error);
|
||||
return NextResponse.json(
|
||||
{ error: 'Failed to fetch status data' },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user