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 ++++++++--
EsApi.go | 4 ++--
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/EsApi.go b/EsApi.go
index 994e456..82eeb03 100644
--- a/EsApi.go
+++ b/EsApi.go
@@ -296,7 +296,7 @@
}
}
],
- "size": 100000000
+ "size": 100
},
"aggs":{
"top_attention_hits":{
@@ -402,7 +402,7 @@
}
}
],
- "size": 100000000
+ "size": 100
},
"aggs":{
"top_attention_hits":{
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