adjust init population

This commit is contained in:
MacBook Air M1
2026-01-06 17:23:06 +07:00
parent 82a7bada05
commit f5a016b74b
2 changed files with 19 additions and 18 deletions
@@ -318,7 +318,8 @@ func mapRecordingToProductionResultDTO(record entity.Recording) dto.ProductionRe
result.Fi = float64(*record.CumIntake)
}
avgWeight := calculateAverageBodyWeight(record.BodyWeights)
// avgWeight := calculateAverageBodyWeight(record.BodyWeights)
avgWeight := 1.0
if avgWeight > 0 {
result.Bw = avgWeight
}
@@ -350,25 +351,25 @@ func mapRecordingToProductionResultDTO(record entity.Recording) dto.ProductionRe
return result
}
func calculateAverageBodyWeight(bodyWeights []entity.RecordingBW) float64 {
var totalQty float64
var totalWeight float64
// func calculateAverageBodyWeight(bodyWeights []entity.RecordingBW) float64 {
// var totalQty float64
// var totalWeight float64
for _, bw := range bodyWeights {
totalQty += bw.Qty
if bw.TotalWeight > 0 {
totalWeight += bw.TotalWeight
} else {
totalWeight += bw.AvgWeight * bw.Qty
}
}
// for _, bw := range bodyWeights {
// totalQty += bw.Qty
// if bw.TotalWeight > 0 {
// totalWeight += bw.TotalWeight
// } else {
// totalWeight += bw.AvgWeight * bw.Qty
// }
// }
if totalQty == 0 {
return 0
}
// if totalQty == 0 {
// return 0
// }
return totalWeight / totalQty
}
// return totalWeight / totalQty
// }
type eggSummary struct {
TotalQty int64