All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.nemerosa.ontrack.model.support.ConnectorGlobalStatus.kt Maven / Gradle / Ivy

There is a newer version: 4.4.5
Show newest version
package net.nemerosa.ontrack.model.support

import kotlin.math.roundToInt

class ConnectorGlobalStatus(
        val statuses: List
) {
    val count = statuses.size

    val upCount = statuses.count { it.status.type == ConnectorStatusType.UP }
    val downCount = statuses.count { it.status.type == ConnectorStatusType.DOWN }

    val status: ConnectorStatusType = if (downCount > 0) ConnectorStatusType.DOWN else ConnectorStatusType.UP

    val percent: Int = if (count > 0) {
        (upCount.toDouble() * 100.0 / count).roundToInt()
    } else {
        100
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy