Source:
<code>public static Integer getSleepDurationScoreV2(final int userAgeInYears, final Integer sleepDurationMinutes) { final SleepDuration.recommendation idealHours = SleepDuration.getSleepDurationRecommendation(userAgeInYears); final Float sleepDurationHours = (float) sleepDurationMinutes / 60.0f; <START> float baseScore; <END> float topScore; float diffMinutes; float bucketTotalMinutes; if (sleepDurationHours < DURATION_V2_MIN_SCORE_HOURS) { return DURATION_MIN_SCORE; } else if (sleepDurationHours > DURATION_TOO_MUCH_HOURS) { return DURATION_TOO_MUCH_SCORE; } else if (sleepDurationHours < idealHours.absoluteMinHours) { baseScore = (float) DURATION_MIN_SCORE; topScore = 70.0f; bucketTotalMinutes = idealHours.absoluteMinHours - DURATION_V2_MIN_SCORE_HOURS; diffMinutes = sleepDurationMinutes - (DURATION_V2_MIN_SCORE_HOURS * 60.0f); } else if (sleepDurationHours < idealHours.maxHours) { baseScore = 70.0f; topScore = 95.0f; bucketTotalMinutes = idealHours.maxHours - idealHours.absoluteMinHours; diffMinutes = sleepDurationMinutes - (idealHours.absoluteMinHours * 60.0f); } else if (sleepDurationHours < idealHours.absoluteMaxHours) { baseScore = 90.0f; topScore = 70.0f; bucketTotalMinutes = idealHours.absoluteMaxHours - idealHours.maxHours; diffMinutes = sleepDurationMinutes - (idealHours.maxHours * 60.0f); } else { baseScore = 70.0f; topScore = DURATION_TOO_MUCH_SCORE; bucketTotalMinutes = DURATION_TOO_MUCH_HOURS - idealHours.absoluteMaxHours; diffMinutes = sleepDurationMinutes - (idealHours.absoluteMaxHours) * 60.0f; } return Math.round(baseScore + diffMinutes * ((topScore - baseScore) / (bucketTotalMinutes * 60.0f))); }</code><technical_language>final</technical_language>

Target:
public static Integer getSleepDurationScoreV2(final int userAgeInYears, final Integer sleepDurationMinutes) { final SleepDuration.recommendation idealHours = SleepDuration.getSleepDurationRecommendation(userAgeInYears); final Float sleepDurationHours = (float) sleepDurationMinutes / 60.0f; final float baseScore; final float topScore; final float diffMinutes; final float bucketTotalMinutes; if (sleepDurationHours < DURATION_V2_MIN_SCORE_HOURS) { return DURATION_MIN_SCORE; } else if (sleepDurationHours > DURATION_TOO_MUCH_HOURS) { return DURATION_TOO_MUCH_SCORE; } else if (sleepDurationHours < idealHours.absoluteMinHours) { baseScore = (float) DURATION_MIN_SCORE; topScore = 70.0f; bucketTotalMinutes = idealHours.absoluteMinHours - DURATION_V2_MIN_SCORE_HOURS; diffMinutes = sleepDurationMinutes - (DURATION_V2_MIN_SCORE_HOURS * 60.0f); } else if (sleepDurationHours < idealHours.maxHours) { baseScore = 70.0f; topScore = 95.0f; bucketTotalMinutes = idealHours.maxHours - idealHours.absoluteMinHours; diffMinutes = sleepDurationMinutes - (idealHours.absoluteMinHours * 60.0f); } else if (sleepDurationHours < idealHours.absoluteMaxHours) { baseScore = 90.0f; topScore = 70.0f; bucketTotalMinutes = idealHours.absoluteMaxHours - idealHours.maxHours; diffMinutes = sleepDurationMinutes - (idealHours.maxHours * 60.0f); } else { baseScore = 70.0f; topScore = DURATION_TOO_MUCH_SCORE; bucketTotalMinutes = DURATION_TOO_MUCH_HOURS - idealHours.absoluteMaxHours; diffMinutes = sleepDurationMinutes - (idealHours.absoluteMaxHours) * 60.0f; } return Math.round(baseScore + diffMinutes * ((topScore - baseScore) / (bucketTotalMinutes * 60.0f))); }