sunty
2020-08-26 859810ec55a27fe55b98ec7ea597f712802f47a8
fix stay time
2个文件已修改
25 ■■■■■ 已修改文件
EsApi.go 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
EsClient.go 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
EsApi.go
@@ -296,7 +296,7 @@
                        }
                    }
                ],
                "size": 100
                "size": 10000000
            },
            "aggs":{
                "top_attention_hits":{
@@ -402,7 +402,7 @@
                        }
                    }
                ],
                "size": 100
                "size": 10000000
            },
            "aggs":{
                "top_attention_hits":{
EsClient.go
@@ -533,20 +533,23 @@
            sTime := tmpTime
            eTime := tmpTime
            stayTime := 0.0
            if startTime != "" && point < indexLength{
            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)
                if passTime <= thresholdTime {
                    startTime = tmpTime
                    hitsSources[len(hitsSources)-1]["endTime"] = tmpTime
                    if point == indexLength{
                        hitStartTime := hitsSources[len(hitsSources)-1]["startTime"].(string)
                        realStartTime, _ := time.ParseInLocation("2006-01-02 15:04:05", hitStartTime, loc)
                        stayTime = math.Abs(mTime.Sub(realStartTime).Seconds())
                        hitsSources[len(hitsSources)-1]["stayTime"] = stayTime
                    }
                    continue
                } else {
                    hitStartTime := hitsSources[len(hitsSources)-1]["startTime"].(string)
                    realStartTime, _ := time.ParseInLocation("2006-01-02 15:04:05", hitStartTime, loc)
                    //fmt.Println("hitStartTime:    ",hitStartTime)
                    //fmt.Println("realStartTime:    ",realStartTime)
                    //fmt.Println("mTime:    ",mTime)
                    stayTime = math.Abs(mTime.Sub(realStartTime).Seconds())
                    //fmt.Println("stayTime:    ",stayTime)
                    hitsSources[len(hitsSources)-1]["endTime"] = tmpTime
@@ -654,13 +657,19 @@
            sTime := tmpTime
            eTime := tmpTime
            stayTime := 0.0
            if startTime != "" && point < indexLength{
            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)
                if passTime <= thresholdTime {
                if passTime <= thresholdTime || point == indexLength{
                    startTime = tmpTime
                    hitsSources[len(hitsSources)-1]["endTime"] = tmpTime
                    if point == indexLength{
                        hitStartTime := hitsSources[len(hitsSources)-1]["startTime"].(string)
                        realStartTime, _ := time.ParseInLocation("2006-01-02 15:04:05", hitStartTime, loc)
                        stayTime = math.Abs(mTime.Sub(realStartTime).Seconds())
                        hitsSources[len(hitsSources)-1]["stayTime"] = stayTime
                    }
                    continue
                } else {
                    hitStartTime := hitsSources[len(hitsSources)-1]["startTime"].(string)