Skip to content
Snippets Groups Projects
Verified Commit 6ab4f36e authored by Jan-Niclas Strüwer's avatar Jan-Niclas Strüwer
Browse files

Merge branch 'main' into dev

parents e9678fad 7cf942c2
No related branches found
No related tags found
No related merge requests found
......@@ -43,21 +43,21 @@ class ToolRunService(
* Lastly, we update the tool run with all tools, which provided results for the given repository,
* and store this to the DB.
*/
suspend fun createToolRunForRepository(repoId: Long) = defaultScope.launch {
suspend fun createToolRunForRepository(projectId: Long) = defaultScope.launch {
/**
* Create initial db models.
* If this fails we want the whole method to fail as we can't continue
* without the db models.
*
*/
logger.info("Starting tool run creation for repo $repoId")
logger.info("Starting tool run creation for repo $projectId")
val toolRun = async(ioScope.coroutineContext) {
val repoDto = repositoryService.getRepositoryInfo(repoId)
val repoDto = repositoryService.getRepositoryInfo(projectId)
val repo = repositoryService.getOrCreate(repoDto)
val tr = createToolRunForRepository(repo)
tr
}.await()
logger.info("Finished tool run creation for repo $repoId $toolRun")
logger.info("Finished tool run creation for repo $projectId $toolRun")
/**
* For all tools, we in parallel query the tool results API.
......@@ -68,11 +68,11 @@ class ToolRunService(
* Lastly, we update the tool run object with all tools,
* which returned results for this repository.
*/
logger.info("Starting batch API query for repo $repoId")
logger.info("Starting batch API query for repo $projectId")
val apiJobs = listOf(
async {
val vulnerabilityDtos =
ortService.getOrtResults(106) // in the dev setup we get results for repo id 106
ortService.getOrtResults(projectId) // in the dev setup we get results for repo id 106
if (vulnerabilityDtos.isNotEmpty()) {
toolRun.toolEntities.add(ortService.toolEntity)
}
......@@ -80,13 +80,13 @@ class ToolRunService(
},
async {
val repoDetailsDto = repositoryDetailsService.getRepositoryDetails(repoId)
val repoDetailsDto = repositoryDetailsService.getRepositoryDetails(projectId)
toolRun.toolEntities.add(repositoryDetailsService.toolEntity)
kpiService.calculateRepositoryDetailsKpis(repoDetailsDto)
},
async {
val rawOccmdResults = occmdService.runOccmd(repoId, toolRun.repository.url)
val rawOccmdResults = occmdService.runOccmd(projectId, toolRun.repository.url)
if (rawOccmdResults.isNotEmpty()) {
toolRun.toolEntities.add(occmdService.toolEntity)
}
......@@ -108,16 +108,16 @@ class ToolRunService(
}
}.flatten()
logger.info("All API queries finished for repo $repoId. Calculated ${kpis.size} raw KPIs.")
logger.info("All API queries finished for repo $projectId. Calculated ${kpis.size} raw KPIs.")
if (kpis.isNotEmpty()) {
logger.info("Purging and storing new KPIs for repo $repoId")
logger.info("Purging and storing new KPIs for repo $projectId")
val kpiEntities = kpiService.saveRawKpis(toolRun, kpis)
toolRun.kpiEntities.addAll(kpiEntities)
saveToolRunEntity(toolRun)
}
logger.info("Finished processing repository changed request for repository $repoId")
logger.info("Finished processing repository changed request for repository $projectId")
}
fun createToolRunForRepository(repo: RepositoryEntity): ToolRunEntity {
......@@ -150,7 +150,7 @@ class ToolRunService(
apiJobs.add(
defaultScope.async {
// TODO: this will be replaced by an API call
val rawOrtResult = ortService.getOrtResults(106)
val rawOrtResult = ortService.getOrtResults(repoId = repo.projectId)
val findings = ortService.getFindings(rawOrtResult)
tool.toolType.toViewModel(findings = findings)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment

Consent

On this website, we use the web analytics service Matomo to analyze and review the use of our website. Through the collected statistics, we can improve our offerings and make them more appealing for you. Here, you can decide whether to allow us to process your data and set corresponding cookies for these purposes, in addition to technically necessary cookies. Further information on data protection—especially regarding "cookies" and "Matomo"—can be found in our privacy policy. You can withdraw your consent at any time.