Browse Source

fix: 邮件推送限制

hsun 1 year ago
parent
commit
9264833c27
1 changed files with 8 additions and 2 deletions
  1. 8 2
      services/index.go

+ 8 - 2
services/index.go

@@ -283,7 +283,12 @@ func IndexRefreshMethanol() {
 
 func IndexRefreshTimely() {
 	fmt.Println("IndexRefreshTimely")
-	go alarm_msg.SendAlarmMsg(utils.APPNAME+" 及时刷新指标", 3)
+	listLen := 0
+	defer func() {
+		if listLen > 0 {
+			go alarm_msg.SendAlarmMsg(utils.APPNAME+" 及时刷新指标", 3)
+		}
+	}()
 
 	//indexObj := new(index.BaseFromMysteelChemicalIndex)
 	//list, err := indexObj.GetIndexRefreshMethanolByTimely()
@@ -292,8 +297,9 @@ func IndexRefreshTimely() {
 		fmt.Println("GetIndexRefreshAll Err:" + err.Error())
 		return
 	}
+	listLen = len(list)
 	fmt.Println("listLen:", len(list))
-	if len(list) <= 0 {
+	if listLen <= 0 {
 		return
 	}
 	now := time.Now()