diff --git a/Backend/src/controllers/AuditController.ts b/Backend/src/controllers/AuditController.ts index 5de912fc..a78c8d5a 100644 --- a/Backend/src/controllers/AuditController.ts +++ b/Backend/src/controllers/AuditController.ts @@ -169,8 +169,8 @@ export class AuditController { throw new ValidationError('No token provided'); } - if (days < 30) { - throw new ValidationError('Cannot delete logs newer than 30 days'); + if (days < 6) { + throw new ValidationError('Cannot delete logs newer than 6 days'); } const deleted = await auditService.deleteOldLogs(days); diff --git a/Backend/src/services/CoursesStudent.service.ts b/Backend/src/services/CoursesStudent.service.ts index f7b7c681..986695b1 100644 --- a/Backend/src/services/CoursesStudent.service.ts +++ b/Backend/src/services/CoursesStudent.service.ts @@ -341,15 +341,17 @@ export class CoursesStudentService { } // Update last_accessed_at (fire-and-forget — ไม่ block response) - prisma.enrollment.update({ - where: { - unique_enrollment: { - user_id: decoded.id, - course_id, + if (enrollment.status === 'ENROLLED') { + prisma.enrollment.update({ + where: { + unique_enrollment: { + user_id: decoded.id, + course_id, + }, }, - }, - data: { last_accessed_at: new Date() }, - }).catch(err => logger.warn(`Failed to update last_accessed_at: ${err}`)); + data: { last_accessed_at: new Date() }, + }).catch(err => logger.warn(`Failed to update last_accessed_at: ${err}`)); + } // Get all lesson progress for this user and course const lessonIds = course.chapters.flatMap(ch => ch.lessons.map(l => l.id));