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'); throw new ValidationError('No token provided');
} }
if (days < 30) { if (days < 6) {
throw new ValidationError('Cannot delete logs newer than 30 days'); throw new ValidationError('Cannot delete logs newer than 6 days');
} }
const deleted = await auditService.deleteOldLogs(days); const deleted = await auditService.deleteOldLogs(days);

View file

@ -341,6 +341,7 @@ export class CoursesStudentService {
} }
// Update last_accessed_at (fire-and-forget — ไม่ block response) // Update last_accessed_at (fire-and-forget — ไม่ block response)
if (enrollment.status === 'ENROLLED') {
prisma.enrollment.update({ prisma.enrollment.update({
where: { where: {
unique_enrollment: { unique_enrollment: {
@ -350,6 +351,7 @@ export class CoursesStudentService {
}, },
data: { last_accessed_at: new Date() }, data: { last_accessed_at: new Date() },
}).catch(err => logger.warn(`Failed to update last_accessed_at: ${err}`)); }).catch(err => logger.warn(`Failed to update last_accessed_at: ${err}`));
}
// Get all lesson progress for this user and course // Get all lesson progress for this user and course
const lessonIds = course.chapters.flatMap(ch => ch.lessons.map(l => l.id)); const lessonIds = course.chapters.flatMap(ch => ch.lessons.map(l => l.id));