feat: Reduce minimum audit log deletion period to 6 days and update enrollment last access only for active enrollments.
All checks were successful
Build and Deploy Backend / Build Backend Docker Image (push) Successful in 26s
Build and Deploy Backend / Deploy E-learning Backend to Dev Server (push) Successful in 3s
Build and Deploy Backend / Notify Deployment Status (push) Successful in 1s

This commit is contained in:
JakkrapartXD 2026-02-23 13:54:03 +07:00
parent ce2a472cac
commit 0588ad7acd
2 changed files with 12 additions and 10 deletions

View file

@ -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);

View file

@ -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));