From 34c030a58af247ceb71205bc68a886a1f55dcc0b Mon Sep 17 00:00:00 2001 From: sunty <1172534965@qq.com> Date: 星期三, 26 八月 2020 12:58:41 +0800 Subject: [PATCH] fix stay time --- EsClient.go | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/EsClient.go b/EsClient.go index 9a19612..8fbbcdf 100644 --- a/EsClient.go +++ b/EsClient.go @@ -507,7 +507,10 @@ middleHits := topAttentionHits["hits"].(map[string]interface{}) finalHits := middleHits["hits"].([]interface{}) startTime := "" + indexLength := len(finalHits) + point := 0 for _, in := range finalHits { + point = point+1 tmpHitSource := make(map[string]interface{}) tmpbuf, ok := in.(map[string]interface{}) if !ok { @@ -530,7 +533,7 @@ sTime := tmpTime eTime := tmpTime stayTime := 0.0 - if startTime != "" { + if startTime != "" && point < indexLength{ sinTime, _ := time.ParseInLocation("2006-01-02 15:04:05", startTime, loc) passTime := math.Abs(mTime.Sub(sinTime).Seconds()) //fmt.Println("passTime: ", passTime) @@ -624,8 +627,11 @@ topAttentionHits := inf.(map[string]interface{})["top_attention_hits"].(map[string]interface{}) middleHits := topAttentionHits["hits"].(map[string]interface{}) finalHits := middleHits["hits"].([]interface{}) + indexLength := len(finalHits) + point := 0 startTime := "" for _, in := range finalHits { + point = point+1 tmpHitSource := make(map[string]interface{}) tmpbuf, ok := in.(map[string]interface{}) if !ok { @@ -648,7 +654,7 @@ sTime := tmpTime eTime := tmpTime stayTime := 0.0 - if startTime != "" { + if startTime != "" && point < indexLength{ sinTime, _ := time.ParseInLocation("2006-01-02 15:04:05", startTime, loc) passTime := math.Abs(mTime.Sub(sinTime).Seconds()) //fmt.Println("passTime: ", passTime) -- Gitblit v1.8.0