chore: translate all Spanish comments and log messages to English
This commit is contained in:
@@ -7,7 +7,7 @@ use crate::common::errors::Result;
|
||||
use crate::domain::repositories::trash_repository::TrashRepository;
|
||||
use crate::application::ports::trash_ports::TrashUseCase;
|
||||
|
||||
/// Servicio para la limpieza automática de elementos expirados en la papelera
|
||||
/// Service for automatic cleanup of expired items in the trash
|
||||
pub struct TrashCleanupService {
|
||||
trash_service: Arc<dyn TrashUseCase>,
|
||||
trash_repository: Arc<dyn TrashRepository>,
|
||||
@@ -23,75 +23,75 @@ impl TrashCleanupService {
|
||||
Self {
|
||||
trash_service,
|
||||
trash_repository,
|
||||
cleanup_interval_hours: cleanup_interval_hours.max(1), // Mínimo 1 hora
|
||||
cleanup_interval_hours: cleanup_interval_hours.max(1), // Minimum 1 hour
|
||||
}
|
||||
}
|
||||
|
||||
/// Inicia el trabajo de limpieza periódica
|
||||
/// Starts the periodic cleanup job
|
||||
#[instrument(skip(self))]
|
||||
pub async fn start_cleanup_job(&self) {
|
||||
let trash_repository = self.trash_repository.clone();
|
||||
let trash_service = self.trash_service.clone();
|
||||
let interval_hours = self.cleanup_interval_hours;
|
||||
|
||||
info!("Iniciando trabajo de limpieza de papelera con intervalo de {} horas", interval_hours);
|
||||
info!("Starting trash cleanup job with interval of {} hours", interval_hours);
|
||||
|
||||
tokio::spawn(async move {
|
||||
let interval_duration = Duration::from_secs(interval_hours * 60 * 60);
|
||||
let mut interval = time::interval(interval_duration);
|
||||
|
||||
// Primera ejecución inmediata
|
||||
// First immediate execution
|
||||
Self::cleanup_expired_items(trash_repository.clone(), trash_service.clone()).await
|
||||
.unwrap_or_else(|e| error!("Error en la limpieza inicial de la papelera: {:?}", e));
|
||||
.unwrap_or_else(|e| error!("Error in initial trash cleanup: {:?}", e));
|
||||
|
||||
loop {
|
||||
interval.tick().await;
|
||||
debug!("Ejecutando tarea programada de limpieza de papelera");
|
||||
debug!("Running scheduled trash cleanup task");
|
||||
|
||||
if let Err(e) = Self::cleanup_expired_items(
|
||||
trash_repository.clone(),
|
||||
trash_service.clone()
|
||||
).await {
|
||||
error!("Error en la limpieza programada de la papelera: {:?}", e);
|
||||
error!("Error in scheduled trash cleanup: {:?}", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// Limpia los elementos expirados en la papelera
|
||||
/// Cleans up expired items in the trash
|
||||
#[instrument(skip(trash_repository, trash_service))]
|
||||
async fn cleanup_expired_items(
|
||||
trash_repository: Arc<dyn TrashRepository>,
|
||||
trash_service: Arc<dyn TrashUseCase>,
|
||||
) -> Result<()> {
|
||||
debug!("Comenzando limpieza de elementos expirados en la papelera");
|
||||
debug!("Starting cleanup of expired items in the trash");
|
||||
|
||||
// Obtener todos los elementos expirados
|
||||
// Get all expired items
|
||||
let expired_items = trash_repository.get_expired_items().await?;
|
||||
|
||||
if expired_items.is_empty() {
|
||||
debug!("No hay elementos expirados para limpiar");
|
||||
debug!("No expired items to clean up");
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
info!("Encontrados {} elementos expirados para eliminar", expired_items.len());
|
||||
info!("Found {} expired items to delete", expired_items.len());
|
||||
|
||||
// Eliminar cada elemento expirado
|
||||
// Delete each expired item
|
||||
for item in expired_items {
|
||||
let trash_id = item.id().to_string();
|
||||
let user_id = item.user_id().to_string();
|
||||
|
||||
debug!("Eliminando elemento expirado: id={}, user={}", trash_id, user_id);
|
||||
debug!("Deleting expired item: id={}, user={}", trash_id, user_id);
|
||||
|
||||
// Si falla una eliminación, continuar con las demás
|
||||
// If a deletion fails, continue with the rest
|
||||
if let Err(e) = trash_service.delete_permanently(&trash_id, &user_id).await {
|
||||
error!("Error eliminando elemento expirado {}: {:?}", trash_id, e);
|
||||
error!("Error deleting expired item {}: {:?}", trash_id, e);
|
||||
} else {
|
||||
debug!("Elemento expirado eliminado correctamente: {}", trash_id);
|
||||
debug!("Expired item deleted successfully: {}", trash_id);
|
||||
}
|
||||
}
|
||||
|
||||
info!("Limpieza de papelera completada");
|
||||
info!("Trash cleanup completed");
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user