From e012f2c5e7c6bc79277ff3317efae7d952a18d22 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期四, 12 十二月 2024 21:10:27 +0800 Subject: [PATCH] 增加频次过滤 --- models/gather_model.go | 15 ++++++++++++++- db/task_results.go | 1 + 2 files changed, 15 insertions(+), 1 deletions(-) diff --git a/db/task_results.go b/db/task_results.go index b90a943..e94c98a 100644 --- a/db/task_results.go +++ b/db/task_results.go @@ -18,6 +18,7 @@ Location string `json:"location" gorm:"type:varchar(255)"` //鍙戠敓鍦扮偣 Building string `json:"building" gorm:"type:varchar(255);"` //妤兼爧 Floor string `json:"floor" gorm:"type:varchar(255);"` //妤煎眰 + PicDate string `json:"picDate" gorm:"type:varchar(255);"` //鎶撴媿鏃堕棿 } func (m *ModelTaskResults) TableName() string { diff --git a/models/gather_model.go b/models/gather_model.go index fc55b84..909c01f 100644 --- a/models/gather_model.go +++ b/models/gather_model.go @@ -227,6 +227,19 @@ }, }, }, + "frequency_filter": map[string]interface{}{ // 娣诲姞棰戠巼杩囨护 + "bucket_selector": map[string]interface{}{ + "buckets_path": map[string]interface{}{ + "eventCount": "_count", // 鑱氬悎浜嬩欢娆℃暟 + }, + "script": map[string]interface{}{ + "source": "params.eventCount >= params.threshold", // 绛涢�夐鐜囪揪鍒伴槇鍊肩殑浜嬩欢 + "params": map[string]interface{}{ + "threshold": gatherModel.Threshold, + }, + }, + }, + }, }, }, }, @@ -294,7 +307,7 @@ if gatherEvents, ok := floorBucket.(map[string]interface{})["gather_events"].(map[string]interface{})["buckets"].([]interface{}); ok { for _, eventBucket := range gatherEvents { key := int64(eventBucket.(map[string]interface{})["key"].(float64)) / 1000 // 灏嗘绉掕浆鎹负绉� - timestamp := time.Unix(key, 0).Format("2006-01-02T15:04:05") + timestamp := time.Unix(key, 0).Format("2006-01-02 15:04:05") // 瑙f瀽浜哄憳 if peopleBuckets, ok := eventBucket.(map[string]interface{})["people"].(map[string]interface{})["buckets"].([]interface{}); ok { -- Gitblit v1.8.0