in codelabs/health_data_analysis_codelab/src/usleep/workload.go [170:192]
func calculateSleepQuality(healthData healthData) string {
fmt.Printf("Sleep data: %v\n", healthData)
totalSleepMins := healthData.Sleep.Light.Minutes + healthData.Sleep.Deep.Minutes + healthData.Sleep.Rem.Minutes
if totalSleepMins > 480 {
return "total sleep time is less than 8 hours"
}
if healthData.Sleep.Rem.Minutes/totalSleepMins < .20 {
return "rem sleep time is less than 25% of total sleep time"
}
if healthData.Sleep.Light.Minutes/totalSleepMins < .50 {
return "light sleep time is less than 50% of total sleep time"
}
if healthData.Sleep.Deep.Minutes/totalSleepMins < .20 {
return "deep sleep time is less than 25% of total sleep time"
}
return "great sleep!"
}