Browse Source

调整智能表单执行时间

boweniac 5 days ago
parent
commit
503df1d845
1 changed files with 14 additions and 10 deletions
  1. 14 10
      crontask/contact_form.go

+ 14 - 10
crontask/contact_form.go

@@ -128,16 +128,20 @@ func (l *CronTask) analyze() {
 	predicates = append(predicates, usagedetail.AppIn(1, 3, 4, 5))
 	//yesterdayStart := time.Now().AddDate(0, 0, -1).Truncate(24 * time.Hour)
 	//yesterdayEnd := yesterdayStart.Add(24 * time.Hour)
-	yesterdayEnd := time.Now().Truncate(24 * time.Hour)
-	yesterdayStart := yesterdayEnd.AddDate(0, 0, -1)
-	predicates = append(predicates, usagedetail.CreatedAtGTE(yesterdayStart))
-	predicates = append(predicates, usagedetail.CreatedAtLT(yesterdayEnd))
-	logx.Info("yesterdayEnd: ", yesterdayEnd)
-	logx.Info("yesterdayStart: ", yesterdayStart)
-	//todayStart := time.Now().AddDate(0, 0, 0).Truncate(24 * time.Hour)
-	//todayEnd := todayStart.Add(24 * time.Hour)
-	//predicates = append(predicates, usagedetail.CreatedAtGTE(todayStart))
-	//predicates = append(predicates, usagedetail.CreatedAtLT(todayEnd))
+
+	//yesterdayEnd := time.Now().Truncate(24 * time.Hour)
+	//yesterdayStart := yesterdayEnd.AddDate(0, 0, -1)
+	//predicates = append(predicates, usagedetail.CreatedAtGTE(yesterdayStart))
+	//predicates = append(predicates, usagedetail.CreatedAtLT(yesterdayEnd))
+	//logx.Info("yesterdayEnd: ", yesterdayEnd)
+	//logx.Info("yesterdayStart: ", yesterdayStart)
+
+	todayStart := time.Now().AddDate(0, 0, 0).Truncate(24 * time.Hour)
+	todayEnd := todayStart.Add(24 * time.Hour)
+	predicates = append(predicates, usagedetail.CreatedAtGTE(todayStart))
+	predicates = append(predicates, usagedetail.CreatedAtLT(todayEnd))
+	logx.Info("todayStart: ", todayStart)
+	logx.Info("todayEnd: ", todayEnd)
 
 	data, err := l.svcCtx.DB.UsageDetail.Query().Where(predicates...).All(l.ctx)
 	logx.Info("usageDetails: ", data)