|
@@ -468,9 +468,8 @@ func (e *Entry) UpdateCowWeeklyHigh(cow *model.Cow) int32 {
|
|
|
weeklyActiveModelList := make([]*model.WeeklyActiveModel, 0)
|
|
|
startTime := time.Now().AddDate(0, 0, -8).Format(model.LayoutDate2)
|
|
|
endTime := time.Now().AddDate(0, 0, -2).Format(model.LayoutDate2)
|
|
|
- selectStr := fmt.Sprintf(`IF(ROUND(AVG( h.high))>%d, ROUND(AVG( h.high)), %d) AS high`, minWeeklyActive.Value, minWeeklyActive.Value)
|
|
|
+ selectStr := fmt.Sprintf(`cow_id,heat_date,count(1) AS nb,IF(ROUND(AVG(high))>%d, ROUND(AVG(high)), %d) AS high`, minWeeklyActive.Value, minWeeklyActive.Value)
|
|
|
if err = e.DB.Model(new(model.NeckActiveHabit)).
|
|
|
- Select("cow_id,heat_date,count(1) AS nb").
|
|
|
Select(selectStr).
|
|
|
Where("cow_id = ?", cow.Id).
|
|
|
Where("heat_date BETWEEN ? AND ?", startTime, endTime).
|