|
@@ -32,7 +32,7 @@ import (
|
|
|
)
|
|
|
|
|
|
const (
|
|
|
- pageSize = 100
|
|
|
+ PageSize = 100
|
|
|
AllSubPushCacheSize = 200
|
|
|
query = `{"query":{"terms":{"_id":["%s"]}},"_source":["_id","area","city", "publishtime", "s_subscopeclass", "subtype", "title", "toptype", "type", "buyerclass","bidamount","budget","projectname","buyer","bidopentime","s_winner","filetext","spidercode","site","buyertel","buyerperson","agency","agencyperson","agencytel","winnerperson","winnertel","signendtime","bidendtime","entidlist","isValidFile","district"],"from":0,"size":%d}`
|
|
|
query1 = `{"query":{"terms":{"_id":["%s"]}},"_source":["_id","area","city", "publishtime", "s_subscopeclass", "subtype", "title", "toptype", "type", "buyerclass","bidamount","budget","projectname","buyer","bidopentime","s_winner","filetext","spidercode","site","buyertel","buyerperson","agency","agencyperson","agencytel","winnerperson","winnertel","signendtime","bidendtime","entidlist","isValidFile", "detail","district"],"from":0,"size":%d}`
|
|
@@ -327,17 +327,17 @@ func subStrDetail(matchKey, detail string) string {
|
|
|
}
|
|
|
return strings.TrimSpace(detail)
|
|
|
}
|
|
|
-func (s *subscribePush) Datas(spqp *SubPushQueryParam, bsp *ViewCondition) (hasNextPage bool, total int64, result []*bxsubscribe.SubscribeInfo) {
|
|
|
- logx.Info(spqp.UserId, spqp.NewUserId, s.ModuleFlag, "subscribePush query param:", "SelectTime:", spqp.SelectTime, "Area:", spqp.Area, "District:", spqp.District, "City:", spqp.City, "Subtype:", spqp.Subtype, "Subscopeclass:", spqp.Subscopeclass, "Buyerclass:", spqp.Buyerclass, "Key:", spqp.Key, "PageNum:", spqp.PageNum, "Price:", spqp.Price, "FileExists:", spqp.FileExists)
|
|
|
+func (s *subscribePush) Datas(spqp *SubPushQueryParam, bsp *ViewCondition) (hasNextPage bool, total int64, result []*bxsubscribe.SubscribeInfo, tipBool bool) {
|
|
|
+ logx.Info(spqp.UserId, spqp.NewUserId, s.ModuleFlag, "subscribePush query param:", "SelectTime:", spqp.SelectTime, "Area:", spqp.Area, "District:", spqp.District, "City:", spqp.City, "Subtype:", spqp.Subtype, "Subscopeclass:", spqp.Subscopeclass, "Buyerclass:", spqp.Buyerclass, "Key:", spqp.Key, "PageNum:", spqp.PageNum, "Price:", spqp.Price, "FileExists:", spqp.FileExists, "SubPushInactive:", spqp.SubPushInactive)
|
|
|
if spqp.UserId == "" {
|
|
|
return
|
|
|
}
|
|
|
if spqp.PageNum < 1 {
|
|
|
spqp.PageNum = 1
|
|
|
}
|
|
|
- if spqp.PageSize < 1 || spqp.PageSize > pageSize {
|
|
|
+ if spqp.PageSize <= 1 || spqp.PageSize > PageSize {
|
|
|
if !spqp.Export {
|
|
|
- spqp.PageSize = pageSize
|
|
|
+ spqp.PageSize = PageSize
|
|
|
} else { //数据导出查询20000条限制
|
|
|
if spqp.PageSize < 1 || spqp.PageSize > 20000 {
|
|
|
spqp.PageSize = 20000
|
|
@@ -364,6 +364,9 @@ func (s *subscribePush) Datas(spqp *SubPushQueryParam, bsp *ViewCondition) (hasN
|
|
|
}
|
|
|
result, total = s.inactiveQuery(spqp, bsp)
|
|
|
hasNextPage = len(result) >= spqp.PageSize
|
|
|
+ if total > 0 {
|
|
|
+ tipBool = true
|
|
|
+ }
|
|
|
return
|
|
|
}
|
|
|
nowFormat := date.NowFormat(date.Date_Short_Layout)
|
|
@@ -515,9 +518,13 @@ func (s *subscribePush) inactiveQuery(spqp *SubPushQueryParam, bsp *ViewConditio
|
|
|
starttime = time.Now().AddDate(0, 0, -15).Unix()
|
|
|
endtime = time.Now().Unix()
|
|
|
}
|
|
|
- qstr := s.getFreeDatasSQL(bsp, starttime, endtime, (spqp.PageNum-1)*spqp.PageSize, spqp.PageSize)
|
|
|
+ qstr := s.getFreeDatasSQL(bsp, starttime, endtime, (spqp.PageNum-1)*spqp.PageSize)
|
|
|
+ log.Println("inactiveQuery---:", qstr)
|
|
|
//list = elastic.GetAllByNgram(INDEX, TYPE, qstr, findfields, bidSort, bidField, 0, 4500, 0, false)
|
|
|
count, list = elastic.GetWithCount(INDEX, TYPE, "", qstr)
|
|
|
+ if len(*list) > spqp.PageSize {
|
|
|
+ *list = (*list)[:spqp.PageSize]
|
|
|
+ }
|
|
|
}
|
|
|
if count > 500 {
|
|
|
count = 500
|
|
@@ -1327,7 +1334,7 @@ func (s *subscribePush) DefaultDatas(spqp *SubPushQueryParam, bsp *ViewCondition
|
|
|
if spqp.UserId == "" {
|
|
|
return false, 0, nil
|
|
|
}
|
|
|
- logx.Info("userId:", spqp.UserId, "newUserId:", spqp.NewUserId)
|
|
|
+ logx.Info("---userId:", spqp.UserId, "newUserId:", spqp.NewUserId)
|
|
|
t1 := time.Now()
|
|
|
if len(bsp.Keyword) > 0 {
|
|
|
logx.Info("--bsp:", bsp)
|
|
@@ -1351,8 +1358,8 @@ func (s *subscribePush) DefaultDatas(spqp *SubPushQueryParam, bsp *ViewCondition
|
|
|
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]
|
|
|
+ if len(result) > PageSize {
|
|
|
+ result = result[:PageSize]
|
|
|
hasNextPage = true
|
|
|
}
|
|
|
}
|
|
@@ -1486,7 +1493,7 @@ func getKeys(title string, keywords []ViewKeyWord) (str []string) {
|
|
|
}
|
|
|
|
|
|
// 获取查询语句
|
|
|
-func (s *subscribePush) getFreeDatasSQL(bsp *ViewCondition, startTime, endTime int64, startNumb, size int) (str string) {
|
|
|
+func (s *subscribePush) getFreeDatasSQL(bsp *ViewCondition, startTime, endTime int64, startNumb int) (str string) {
|
|
|
query := `{"query":{"bool":{"must":[%s],"should":[%s],"minimum_should_match": %d}},"_source":[%s],"sort": [{"publishtime": "desc"}],"from":%d,"size":%d}`
|
|
|
query_bool_should := `{"bool":{"should":[%s],"minimum_should_match": 1}}`
|
|
|
multi_match := `{"multi_match": {"query": %s,"type": "phrase", "fields": [%s]}}`
|
|
@@ -1630,7 +1637,7 @@ func (s *subscribePush) getFreeDatasSQL(bsp *ViewCondition, startTime, endTime i
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- qstr := fmt.Sprintf(query, strings.Join(musts, ","), strings.Join(bools, ","), boolsNum, bidField, startNumb, size)
|
|
|
+ qstr := fmt.Sprintf(query, strings.Join(musts, ","), strings.Join(bools, ","), boolsNum, bidField, startNumb, bsp.Size)
|
|
|
logx.Info("----", qstr)
|
|
|
return qstr
|
|
|
}
|
|
@@ -2461,8 +2468,9 @@ func (s *SubPushQueryParam) ExportPushFormat() (ids, keyWords []string) {
|
|
|
// @Author jianghan
|
|
|
// @Description clickhouse获取推荐的列表数据
|
|
|
// @Date 2024/3/11
|
|
|
-func (s *subscribePush) SubRecList(userId string, keyword []ViewKeyWord) (hasNextPage bool, total int64, resultList []*bxsubscribe.SubscribeInfo) {
|
|
|
- infos := IC.BaseServiceMysql.SelectBySql(`select autoid from push.sub_recommend_list where userid=? order by create_time desc limit ?`, userId, pageSize)
|
|
|
+// 根据用户身份获取数据量:免费50,付费1000
|
|
|
+func (s *subscribePush) SubRecList(userId string, keyword []ViewKeyWord, size int) (hasNextPage bool, total int64, resultList []*bxsubscribe.SubscribeInfo) {
|
|
|
+ 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 {
|
|
|
for _, v := range *infos {
|
|
@@ -2473,9 +2481,12 @@ func (s *subscribePush) SubRecList(userId string, keyword []ViewKeyWord) (hasNex
|
|
|
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)
|
|
|
+ binfo := elastic.GetAllByNgram(INDEX, TYPE, esq, findfields, bidSort, bidField, 0, size, length, false)
|
|
|
if binfo != nil && len(*binfo) > 0 {
|
|
|
- for _, m := range *binfo {
|
|
|
+ for n, m := range *binfo {
|
|
|
+ if n > PageSize {
|
|
|
+ break
|
|
|
+ }
|
|
|
title := strings.Replace(common.ObjToString(m["title"]), " ", "", -1)
|
|
|
matchkeys := getKeys(title, keyword)
|
|
|
resultList = append(resultList, s.InfoFormat(&PushCa{
|
|
@@ -2521,8 +2532,8 @@ func (s *subscribePush) GetRecListByEs() (hasNextPage bool, total int64, resultL
|
|
|
}
|
|
|
}
|
|
|
total = int64(len(resultList))
|
|
|
- if total > pageSize {
|
|
|
- resultList = resultList[:pageSize]
|
|
|
+ if total > PageSize {
|
|
|
+ resultList = resultList[:PageSize]
|
|
|
hasNextPage = true
|
|
|
}
|
|
|
return
|