Refactored LibDepStatistics to include FailedProjects

This commit is contained in:
Šesták Vít
2016-04-28 10:14:50 +02:00
parent 08500f9a5b
commit e3d59cede8
8 changed files with 99 additions and 67 deletions

View File

@@ -0,0 +1,23 @@
package com.ysoft.odc.statistics
import controllers.ReportInfo
final class FailedProjects(val failedProjectsSet: Set[String]){
def isFailed(projectFullId: String): Boolean = {
val projectBareId = projectFullId.takeWhile(_ != '/')
failedProjectsSet contains projectBareId
}
}
object FailedProjects {
private[statistics] def combineFails(failedReportDownloads: Map[String, Throwable], parsingFailures: Map[ReportInfo, Throwable]): FailedProjects = {
/*
Fail can happen at multiple places:
1. Build cannot be downloaded (auth error, connection error, …) or is failed (failedReportDownloads)
2. Build is successful and can be downloaded, but it cannot be parsed (parsingFailures)
*/
val failedProjectsSet = failedReportDownloads.keySet ++ parsingFailures.keySet.map(_.projectId)
new FailedProjects(failedProjectsSet)
}
}