package com.ai.trackwalker.model;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class ModelUploadCleanupJob {
    private static final Logger log = LoggerFactory.getLogger(ModelUploadCleanupJob.class);

    private final ModelManagementService service;

    public ModelUploadCleanupJob(ModelManagementService service) {
        this.service = service;
    }

    @Scheduled(initialDelayString = "${rail.storage.cleanup-initial-delay-ms:60000}",
            fixedDelayString = "${rail.storage.cleanup-interval-ms:3600000}")
    public void cleanupExpiredUploads() {
        int cleaned = service.cleanupExpiredUploadSessions();
        if (cleaned > 0) {
            log.info("已清理 {} 个过期模型测试上传会话", cleaned);
        }
    }
}
