Ver Fonte

no message

Jianghan há 5 anos atrás
pai
commit
7426e90813
1 ficheiros alterados com 4 adições e 2 exclusões
  1. 4 2
      customerdata/src/util.go

+ 4 - 2
customerdata/src/util.go

@@ -213,12 +213,14 @@ func GetIdRange() (bson.M, bool) {
 	defer qu.Catch()
 	now := time.Now().Unix()
 	for { //当前时间一直向前推半小时,直到取到数据
-		now = now - 1800 //半小时
+		now = now - 600 //10分钟
 		endTime := time.Unix(now, 0)
 		endId := bson.NewObjectIdWithTime(endTime).Hex()
 		if endId > LatestId {
-			esquery := `{"query": {"bool": {"must": [{"range": {"id": {"gt": "` + LatestId + `" , "lte": "` + endId + `"}}}]}}}`
+			esquery := `{"query": {"bool": {"must": [{"range": {"id": {"gt": "` + LatestId + `" , "lte": "` + endId + `"}}}]}}, "sort": [{"comeintime": "desc"}]}`
 			if Es.Count(Index, Itype, esquery) > 0 { //有数据返回id区间
+				list := Es.Get(Index, Itype, esquery)
+				endId = qu.ObjToString((*list)[0]["_id"])
 				tmpRange := bson.M{
 					"range": bson.M{
 						"id": bson.M{