فهرست منبع

Merge branch 'dev/dev_v1.1.45_wjh' into feature/v1.1.45

* dev/dev_v1.1.45_wjh:
  去重
Jianghan 1 سال پیش
والد
کامیت
5adb00b405
1فایلهای تغییر یافته به همراه24 افزوده شده و 5 حذف شده
  1. 24 5
      jyBXSubscribe/rpc/model/push.go

+ 24 - 5
jyBXSubscribe/rpc/model/push.go

@@ -1079,11 +1079,19 @@ func (s *subscribePush) DefaultDatas(spqp *SubPushQueryParam, bsp *ViewCondition
 		logx.Info("--bsp:", bsp)
 		//获取查询语句
 		qstr := s.getDefaultDatasSQL(bsp)
-		list := elastic.GetAllByNgram(INDEX, TYPE, qstr, findfields, bidSort, bidField, 0, bsp.Size, 0, false)
-		//logx.Info(time.Since(t1), "count:", len(*list))
+		list := elastic.GetAllByNgram(INDEX, TYPE, qstr, findfields, bidSort, bidField, 0, bsp.Size, 500, false)
+		logx.Info(time.Since(t1), "list count:", len(*list))
 		if list != nil && len(*list) > 0 {
-			total = int64(len(*list))
-			result = s.listManager(spqp, *list, bsp.Keyword)
+			var mlist []map[string]interface{}
+			esM := listHistory(spqp)
+			for _, m := range *list {
+				if !esM[common.ObjToString(m["_id"])] {
+					mlist = append(mlist, m)
+				}
+			}
+			logx.Info(time.Since(t1), "mlist count:", len(mlist))
+			total = int64(len(mlist))
+			result = s.listManager(spqp, mlist, bsp.Keyword)
 			if len(result) > pageSize {
 				result = result[:pageSize]
 				hasNextPage = true
@@ -1094,6 +1102,17 @@ func (s *subscribePush) DefaultDatas(spqp *SubPushQueryParam, bsp *ViewCondition
 	return
 }
 
+// 历史订阅消息
+func listHistory(spqp *SubPushQueryParam) map[string]bool {
+	m := make(map[string]bool)
+	sql := "SELECT infoid FROM push.pushentniche where userid = ? order by date desc, id desc limit 1000;"
+	info := spqp.BaseServiceMysql.SelectBySql(sql, spqp.NewUserId)
+	for _, m1 := range *info {
+		m[common.ObjToString(m1["infoid"])] = true
+	}
+	return m
+}
+
 // 保存推送表
 func (s *subscribePush) listManager(spqp *SubPushQueryParam, list []map[string]interface{}, keyword []ViewKeyWord) (resultList []*bxsubscribe.SubscribeInfo) {
 	now := time.Now().Unix()
@@ -1206,7 +1225,7 @@ func getKeys(title string, keywords []ViewKeyWord) (str []string) {
 
 // 获取查询语句
 func (s *subscribePush) getDefaultDatasSQL(bsp *ViewCondition) (str string) {
-	query := `{"query":{"bool":{"must":[%s],"should":[%s],"minimum_should_match": %d}}, "size": 500}`
+	query := `{"query":{"bool":{"must":[%s],"should":[%s],"minimum_should_match": %d}}}`
 	query_bool_should := `{"bool":{"should":[%s],"minimum_should_match": 1}}`
 	multi_match := `{"multi_match": {"query": %s,"type": "phrase", "fields": [%s]}}`
 	query_bool_must_and := `{"bool":{"must":[%s]%s}}`