diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/toolRun/service/ToolRunService.kt b/src/main/kotlin/de/fraunhofer/iem/dataprovider/toolRun/service/ToolRunService.kt index 5f2050b7e10c27c5e0b591e4fd86d9e221cb4841..53cc23e6edd158d7af16bfa5fdede85180d19a89 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/toolRun/service/ToolRunService.kt +++ b/src/main/kotlin/de/fraunhofer/iem/dataprovider/toolRun/service/ToolRunService.kt @@ -153,7 +153,8 @@ class ToolRunService( */ suspend fun getToolRunForRepository( repo: RepositoryEntity, - dispatcher: CoroutineDispatcher = Dispatchers.IO + dispatcher: CoroutineDispatcher = Dispatchers.IO, + includeFindings: Boolean = false ): ToolRunDto { val toolRunEntity = withContext(dispatcher) { toolRunRepository.findFirstByRepository_IdOrderByCreatedAtDesc(repo.id!!) @@ -161,26 +162,36 @@ class ToolRunService( val apiJobs: MutableList<Deferred<ToolResponseDto>> = mutableListOf() - toolRunEntity.toolEntities.forEach { tool -> - when (tool.toolType) { - ToolType.ORT -> { - apiJobs.add( - defaultScope.async { - // TODO: this will be replaced by an API call - val rawOrtResult = ortService.getOrtResults(projectId = repo.projectId) - val findings = ortService.getFindings(rawOrtResult) - tool.toolType.toViewModel(findings = findings) - } - ) - } - else -> { - apiJobs.add( - defaultScope.async { - tool.toolType.toViewModel() - } - ) + if (includeFindings) { + toolRunEntity.toolEntities.forEach { tool -> + when (tool.toolType) { + ToolType.ORT -> { + apiJobs.add( + defaultScope.async { + val rawOrtResult = ortService.getOrtResults(projectId = repo.projectId) + val findings = ortService.getFindings(rawOrtResult) + tool.toolType.toViewModel(findings = findings) + } + ) + } + + else -> { + apiJobs.add( + defaultScope.async { + tool.toolType.toViewModel() + } + ) + } } } + } else { + toolRunEntity.toolEntities.forEach { tool -> + apiJobs.add( + defaultScope.async { + tool.toolType.toViewModel() + } + ) + } } val tools = apiJobs.mapNotNull {