diff --git a/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/domain/use_cases/controlUnit/GetLegacyControlUnits.kt b/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/domain/use_cases/controlUnit/GetLegacyControlUnits.kt index 177ddc694..239e0b31d 100644 --- a/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/domain/use_cases/controlUnit/GetLegacyControlUnits.kt +++ b/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/domain/use_cases/controlUnit/GetLegacyControlUnits.kt @@ -11,8 +11,15 @@ class GetLegacyControlUnits(private val controlUnitRepository: IControlUnitRepos fun execute(): List { val controlUnits = controlUnitRepository.findAll() - logger.info("Found ${controlUnits.size} control units") + val controlUnitsWithActiveControlUnitResources = controlUnits.map { controlUnit -> + controlUnit.copy( + controlUnitResources = controlUnit.controlUnitResources.filter { + !it.controlUnitResource.isArchived + }, + ) + } + logger.info("Found ${controlUnitsWithActiveControlUnitResources.size} control units.") - return controlUnits.map { it.toLegacyControlUnit() } + return controlUnitsWithActiveControlUnitResources.map { it.toLegacyControlUnit() } } }