diff --git a/services/gdd_service.go b/services/gdd_service.go index 19bef95132a78dbc7c753b04869b7b383278ca67..381e559868d8a3cc539556bf37edcefd4b443b19 100644 --- a/services/gdd_service.go +++ b/services/gdd_service.go @@ -59,10 +59,14 @@ func GetNormalValues(request models.GddRequest) models.GddResponse { sliceDateInt = 0 } - for i := sliceDateInt; i < len(gs[0].MinTemps); i++ { //; i++ { + for i := sliceDateInt; i < len(gs[0].MinTemps)*2; i++ { //; i++ { row := []float64{} + idx := i + if i >= len(gs[0].MinTemps) { + idx -= len(gs[0].MinTemps) + } for j := 0; j < len(gs); j++ { - row = append(row, utils.CalculateSingleGdd(gs[j].MinTemps[i], gs[j].MaxTemps[i], product)) + row = append(row, utils.CalculateSingleGdd(gs[j].MinTemps[idx], gs[j].MaxTemps[idx], product)) if request.Accumulate && i > sliceDateInt { row[j] += rows[len(rows)-1][j] }