|
@@ -2244,33 +2244,33 @@ func (s *SubPushQueryParam) ExportPushFormat() (ids, keyWords []string) {
|
|
// @Description clickhouse获取推荐的列表数据
|
|
// @Description clickhouse获取推荐的列表数据
|
|
// @Date 2024/3/11
|
|
// @Date 2024/3/11
|
|
func (s *subscribePush) SubRecList(userId string, keyword []ViewKeyWord) (hasNextPage bool, total int64, resultList []*bxsubscribe.SubscribeInfo) {
|
|
func (s *subscribePush) SubRecList(userId string, keyword []ViewKeyWord) (hasNextPage bool, total int64, resultList []*bxsubscribe.SubscribeInfo) {
|
|
- //sql := "select bitmapToArray(infoids) infoids, userid from jianyu.sub_recommend_list where userid = ?"
|
|
|
|
- //infos := IC.CkJy.SelectBySql(sql, userId)
|
|
|
|
- //if infos != nil && len(*infos) > 0 {
|
|
|
|
- //if ids, ok := (*infos)[0]["infoids"].([]interface{}); ok && len(ids) > 0 {
|
|
|
|
- ids := []int64{272269745, 272269067, 272268763}
|
|
|
|
- length := len(ids)
|
|
|
|
- resultList = make([]*bxsubscribe.SubscribeInfo, length)
|
|
|
|
- binfo, _ := IC.MgoBidding.Find("bidding", bson.M{"autoid": bson.M{"$in": ids}}, `{"publishtime": -1}`, bidField, false, -1, -1)
|
|
|
|
- if binfo != nil && len(*binfo) > 0 {
|
|
|
|
- for i, m := range *binfo {
|
|
|
|
- title := strings.Replace(common.ObjToString(m["title"]), " ", "", -1)
|
|
|
|
- matchkeys := getKeys(title, keyword)
|
|
|
|
- resultList[i] = s.InfoFormat(&PushCa{
|
|
|
|
- InfoId: mongodb.BsonIdToSId(m["_id"]),
|
|
|
|
- Date: time.Now().Unix(),
|
|
|
|
- Keys: matchkeys,
|
|
|
|
- FileExists: m["filetext"] != nil,
|
|
|
|
- }, &m, false)
|
|
|
|
|
|
+ sql := "select bitmapToArray(infoids) infoids, userid from jianyu.sub_recommend_list where userid = ?"
|
|
|
|
+ infos := IC.CkJy.SelectBySql(sql, userId)
|
|
|
|
+ if infos != nil && len(*infos) > 0 {
|
|
|
|
+ if ids, ok := (*infos)[0]["infoids"].([]uint64); ok && len(ids) > 0 {
|
|
|
|
+ length := len(ids)
|
|
|
|
+ resultList = make([]*bxsubscribe.SubscribeInfo, length)
|
|
|
|
+ esq := `{"query": {"bool": {"must": [{"terms": {"autoid": [` + strings.Join(gconv.Strings(ids), ",") + ` ]}}]}}}`
|
|
|
|
+ binfo := elastic.GetAllByNgram(INDEX, TYPE, esq, findfields, bidSort, bidField, 0, 100, length, false)
|
|
|
|
+ if binfo != nil && len(*binfo) > 0 {
|
|
|
|
+ for i, m := range *binfo {
|
|
|
|
+ title := strings.Replace(common.ObjToString(m["title"]), " ", "", -1)
|
|
|
|
+ matchkeys := getKeys(title, keyword)
|
|
|
|
+ resultList[i] = s.InfoFormat(&PushCa{
|
|
|
|
+ InfoId: mongodb.BsonIdToSId(m["_id"]),
|
|
|
|
+ Date: time.Now().Unix(),
|
|
|
|
+ Keys: matchkeys,
|
|
|
|
+ FileExists: m["filetext"] != nil,
|
|
|
|
+ }, &m, false)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ total = int64(len(resultList))
|
|
|
|
+ if total > pageSize {
|
|
|
|
+ resultList = resultList[:pageSize]
|
|
|
|
+ hasNextPage = true
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- total = int64(len(resultList))
|
|
|
|
- if total > pageSize {
|
|
|
|
- resultList = resultList[:pageSize]
|
|
|
|
- hasNextPage = true
|
|
|
|
- }
|
|
|
|
- //}
|
|
|
|
- //}
|
|
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2291,7 +2291,7 @@ func (s *subscribePush) GetRecListByEs() (hasNextPage bool, total int64, resultL
|
|
}, &data[i], false)
|
|
}, &data[i], false)
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- qstr := `{"query": {"bool": {"must": [{"match_all": {}}]}},"sort": {"publishtime": {"order": "desc"}},"from": 0,"size": 10}`
|
|
|
|
|
|
+ qstr := `{"query": {"bool": {"must": [{"match_all": {}}]}}}`
|
|
list := elastic.GetAllByNgram(INDEX, TYPE, qstr, findfields, bidSort, bidField, 0, 10, 10, false)
|
|
list := elastic.GetAllByNgram(INDEX, TYPE, qstr, findfields, bidSort, bidField, 0, 10, 10, false)
|
|
redis.Put("pushcache_2_c", "bid_sub_recommend", 1, 86400)
|
|
redis.Put("pushcache_2_c", "bid_sub_recommend", 1, 86400)
|
|
for i := 0; i < len(*list); i++ {
|
|
for i := 0; i < len(*list); i++ {
|