testing yuk
This commit is contained in:
@@ -3,12 +3,12 @@ import supabase from '@/lib/db';
|
||||
|
||||
export async function POST() {
|
||||
try {
|
||||
// Get current date
|
||||
// Ambil tanggal saat ini
|
||||
const currentDate = new Date();
|
||||
const currentYear = currentDate.getFullYear();
|
||||
const currentMonth = currentDate.getMonth() + 1; // getMonth() returns 0-11
|
||||
|
||||
// Get all active students
|
||||
// Ambil semua mahasiswa aktif
|
||||
const { data: activeStudents, error: fetchError } = await supabase
|
||||
.from('mahasiswa')
|
||||
.select('nim, tahun_angkatan, semester')
|
||||
@@ -32,7 +32,7 @@ export async function POST() {
|
||||
let updatedCount = 0;
|
||||
const errors: string[] = [];
|
||||
|
||||
// Update semester for each active student
|
||||
// Update semester untuk setiap mahasiswa aktif
|
||||
for (const student of activeStudents) {
|
||||
try {
|
||||
const tahunAngkatan = student.tahun_angkatan;
|
||||
@@ -41,7 +41,7 @@ export async function POST() {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Calculate current semester based on tahun_angkatan and current date
|
||||
// Hitung semester saat ini berdasarkan tahun_angkatan dan tanggal saat ini
|
||||
const years = currentYear - tahunAngkatan;
|
||||
let currentSemester: number;
|
||||
|
||||
@@ -60,7 +60,7 @@ export async function POST() {
|
||||
if (currentSemester < 1) currentSemester = 1;
|
||||
if (currentSemester > 14) currentSemester = 14;
|
||||
|
||||
// Update semester if different
|
||||
// Update semester jika berbeda
|
||||
if (student.semester !== currentSemester) {
|
||||
const { error: updateError } = await supabase
|
||||
.from('mahasiswa')
|
||||
|
||||
Reference in New Issue
Block a user