From 4e5f7a56daebeedd829ab62e260bc5d342b7c494 Mon Sep 17 00:00:00 2001 From: 710leo <710leo@gmail.com> Date: Tue, 24 Mar 2020 11:15:00 +0800 Subject: [PATCH] fix: tagkv api get redundant values --- src/modules/index/cache/tag_map.go | 5 +++-- src/modules/index/http/routes/index_router.go | 4 ++-- src/modules/transfer/http/routes/routes.go | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/modules/index/cache/tag_map.go b/src/modules/index/cache/tag_map.go index 205d5296..dba7a5c8 100644 --- a/src/modules/index/cache/tag_map.go +++ b/src/modules/index/cache/tag_map.go @@ -30,8 +30,9 @@ func (t *TagkvIndex) GetTagkv() []*TagPair { t.RLock() defer t.RUnlock() tagkvs := []*TagPair{} - var vs []string + for k, vm := range t.Tagkv { + var vs []string for v, _ := range vm { vs = append(vs, v) } @@ -50,8 +51,8 @@ func (t *TagkvIndex) GetTagkvMap() map[string][]string { defer t.RUnlock() tagkvs := make(map[string][]string) - var vs []string for k, vm := range t.Tagkv { + var vs []string for v, _ := range vm { vs = append(vs, v) } diff --git a/src/modules/index/http/routes/index_router.go b/src/modules/index/http/routes/index_router.go index c047d972..e5233fe9 100644 --- a/src/modules/index/http/routes/index_router.go +++ b/src/modules/index/http/routes/index_router.go @@ -93,9 +93,8 @@ func GetTagPairs(c *gin.Context) { resp := []*IndexTagkvResp{} - tagkvFilter := make(map[string]map[string]struct{}) - for _, metric := range recv.Metrics { + tagkvFilter := make(map[string]map[string]struct{}) tagkvs := []*cache.TagPair{} for _, endpoint := range recv.Endpoints { @@ -107,6 +106,7 @@ func GetTagPairs(c *gin.Context) { } tagkvMap := metricIndex.TagkvMap.GetTagkvMap() + for tagk, tagvs := range tagkvMap { tagvFilter, exists := tagkvFilter[tagk] if !exists { diff --git a/src/modules/transfer/http/routes/routes.go b/src/modules/transfer/http/routes/routes.go index d6e31563..cec93b7c 100644 --- a/src/modules/transfer/http/routes/routes.go +++ b/src/modules/transfer/http/routes/routes.go @@ -18,7 +18,7 @@ func Config(r *gin.Engine) { sys.GET("/alive-judges", judges) sys.POST("/push", PushData) - sys.POST("/data", QueryDataForJudge) + sys.POST("/data", QueryData) sys.POST("/data/ui", QueryDataForUI) }