|
@@ -189,29 +189,21 @@ func (e *Entry) EntryUpdateActiveHabit(pastureId int64) (err error) {
|
|
|
if err != nil {
|
|
|
zaplog.Error("NeckRingCalculate", zap.Any("FirstFilterUpdate", err), zap.Any("xToday", xToday))
|
|
|
}
|
|
|
-
|
|
|
zaplog.Info("NeckRingCalculate", zap.Any("xToday", xToday), zap.Any("processIds", processIds))
|
|
|
+ if len(processIds) <= 0 {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
|
|
|
- if len(processIds) > 0 {
|
|
|
- if err = e.WeeklyUpdateActiveHabit(pastureId, processIds, xToday); err != nil {
|
|
|
- zaplog.Error("NeckRingCalculate", zap.Any("WeeklyUpdateActiveHabit", err), zap.Any("xToday", xToday))
|
|
|
- }
|
|
|
-
|
|
|
- if err = e.Before3DaysNeckActiveHabit(pastureId, processIds, xToday); err != nil {
|
|
|
- zaplog.Error("NeckRingCalculate", zap.Any("Before3DaysNeckActiveHabit", err), zap.Any("xToday", xToday))
|
|
|
- }
|
|
|
-
|
|
|
- if err = e.SecondUpdateChangeFilter(pastureId, xToday); err != nil {
|
|
|
- zaplog.Error("NeckRingCalculate", zap.Any("SecondUpdateChangeFilter", err), zap.Any("xToday", xToday))
|
|
|
- }
|
|
|
+ if err = e.WeeklyUpdateActiveHabit(pastureId, processIds, xToday); err != nil {
|
|
|
+ zaplog.Error("NeckRingCalculate", zap.Any("WeeklyUpdateActiveHabit", err), zap.Any("xToday", xToday))
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
- if err = e.DB.Model(new(model.NeckRingConfigure)).
|
|
|
- Where("name = ?", model.MaxHabit).
|
|
|
- Where("pasture_id = ?", pastureId).
|
|
|
- Update("value", processIds[len(processIds)-1]).Error; err != nil {
|
|
|
- zaplog.Error("NeckRingCalculate", zap.Any("MaxHabit", err), zap.Any("xToday", xToday))
|
|
|
- }
|
|
|
+ if err = e.Before3DaysNeckActiveHabit(pastureId, processIds, xToday); err != nil {
|
|
|
+ zaplog.Error("NeckRingCalculate", zap.Any("Before3DaysNeckActiveHabit", err), zap.Any("xToday", xToday))
|
|
|
+ }
|
|
|
+
|
|
|
+ if err = e.SecondUpdateChangeFilter(pastureId, xToday); err != nil {
|
|
|
+ zaplog.Error("NeckRingCalculate", zap.Any("SecondUpdateChangeFilter", err), zap.Any("xToday", xToday))
|
|
|
}
|
|
|
|
|
|
|
|
@@ -220,7 +212,7 @@ func (e *Entry) EntryUpdateActiveHabit(pastureId int64) (err error) {
|
|
|
}
|
|
|
|
|
|
if err = e.DB.Model(new(model.NeckActiveHabit)).
|
|
|
- Where("id BETWEEN ? AND ?", xToday.LastMaxHabitId, xToday.CurrMaxHabitId).
|
|
|
+ Where("id IN (?)", processIds).
|
|
|
Where("pasture_id = ?", pastureId).
|
|
|
Where("is_show = ?", pasturePb.IsShow_No).
|
|
|
Where("change_filter = ?", model.InitChangeFilter).
|
|
@@ -233,7 +225,7 @@ func (e *Entry) EntryUpdateActiveHabit(pastureId int64) (err error) {
|
|
|
}
|
|
|
|
|
|
if err = e.DB.Model(new(model.NeckActiveHabit)).
|
|
|
- Where("id BETWEEN ? AND ?", xToday.LastMaxHabitId, xToday.CurrMaxHabitId).
|
|
|
+ Where("id IN (?)", processIds).
|
|
|
Where("pasture_id = ?", pastureId).
|
|
|
Where("change_filter < ?", 0).
|
|
|
Where("filter_correct < ?", model.DefaultFilterCorrect).
|
|
@@ -248,11 +240,25 @@ func (e *Entry) EntryUpdateActiveHabit(pastureId int64) (err error) {
|
|
|
zaplog.Error("EntryUpdateActiveHabit", zap.Any("UpdateChangeAdJust", err), zap.Any("xToday", xToday))
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ if err = e.DB.Model(new(model.NeckActiveHabit)).
|
|
|
+ Where("id IN (?)", processIds).
|
|
|
+ Where("pasture_id = ?", pastureId).
|
|
|
+ Update("is_show", pasturePb.IsShow_Ok).Error; err != nil {
|
|
|
+ zaplog.Error("UpdateChangeAdJust-2", zap.Any("error", err), zap.Any("xToday", xToday))
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if err = e.DB.Model(new(model.NeckRingConfigure)).
|
|
|
+ Where("name = ?", model.MaxHabit).
|
|
|
+ Where("pasture_id = ?", pastureId).
|
|
|
+ Update("value", processIds[len(processIds)-1]).Error; err != nil {
|
|
|
+ zaplog.Error("NeckRingCalculate", zap.Any("MaxHabit", err), zap.Any("xToday", xToday))
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
- if len(processIds) > 0 {
|
|
|
- if err = e.HealthWarning(pastureId, processIds); err != nil {
|
|
|
- zaplog.Error("EntryUpdateActiveHabit", zap.Any("HealthWarning", err))
|
|
|
- }
|
|
|
+ if err = e.HealthWarning(pastureId, processIds); err != nil {
|
|
|
+ zaplog.Error("EntryUpdateActiveHabit", zap.Any("HealthWarning", err))
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
@@ -754,13 +760,6 @@ func (e *Entry) UpdateChangeAdJust(pastureId int64, xToday *XToday) error {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- if err := e.DB.Model(new(model.NeckActiveHabit)).
|
|
|
- Where("id BETWEEN ? AND ?", xToday.LastMaxHabitId, xToday.CurrMaxHabitId).
|
|
|
- Where("pasture_id = ?", pastureId).
|
|
|
- Update("is_show", pasturePb.IsShow_Ok).Error; err != nil {
|
|
|
- zaplog.Error("UpdateChangeAdJust-2", zap.Any("error", err), zap.Any("xToday", xToday))
|
|
|
- }
|
|
|
return nil
|
|
|
}
|
|
|
|