|
@@ -2454,32 +2454,31 @@ 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)
|
|
|
|
|
|
+ infos := IC.BaseServiceMysql.SelectBySql(`select autoid from push.sub_recommend_list where userid=? order by create_time desc limit ?`, userId, pageSize)
|
|
|
|
+ ids := []int64{}
|
|
if infos != nil && len(*infos) > 0 {
|
|
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, false)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- total = int64(len(resultList))
|
|
|
|
- if total > pageSize {
|
|
|
|
- resultList = resultList[:pageSize]
|
|
|
|
- hasNextPage = true
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ for _, v := range *infos {
|
|
|
|
+ ids = append(ids, common.Int64All(v["autoid"]))
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if len(ids) > 0 {
|
|
|
|
+ length := len(ids)
|
|
|
|
+ resultList = []*bxsubscribe.SubscribeInfo{}
|
|
|
|
+ esq := `{"query": {"bool": {"must": [{"terms": {"autoid": [` + strings.Join(gconv.Strings(ids), ",") + ` ]}}]}}}`
|
|
|
|
+ binfo := elastic.GetAllByNgram(INDEX, TYPE, esq, findfields, bidSort, bidField, 0, pageSize, length, false)
|
|
|
|
+ if binfo != nil && len(*binfo) > 0 {
|
|
|
|
+ for _, m := range *binfo {
|
|
|
|
+ title := strings.Replace(common.ObjToString(m["title"]), " ", "", -1)
|
|
|
|
+ matchkeys := getKeys(title, keyword)
|
|
|
|
+ resultList = append(resultList, s.InfoFormat(&PushCa{
|
|
|
|
+ InfoId: mongodb.BsonIdToSId(m["_id"]),
|
|
|
|
+ Date: time.Now().Unix(),
|
|
|
|
+ Keys: matchkeys,
|
|
|
|
+ FileExists: m["filetext"] != nil,
|
|
|
|
+ }, &m, false, false))
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ total = int64(len(resultList))
|
|
}
|
|
}
|
|
return
|
|
return
|
|
}
|
|
}
|