import { CanaryClassifierThresholdsConfig } from '../domain/Kayenta' ; import { safeGet } from './OptionalUtils' ; export function getClassFromScore ( score , canaryScores , scoreThresholds , canaryRunIndex ) { const { pass , marginal } = scoreThresholds ; const isLastCanaryExecution = canaryRunIndex + 1 === safeGet ( ( ) => canaryScores . length ) . orElse ( 0 ) ; if ( isLastCanaryExecution ) { return score < pass ? 'fail' : 'pass' ; } return score >= pass ? 'pass' : score >= marginal ? 'marginal' : 'fail' ; } export function getGroupClassFromScore ( score , scoreThresholds ) { const { pass } = scoreThresholds ; return score >= pass ? 'pass' : 'fail' ; } export default { getClassFromScore , getGroupClassFromScore } ;