by Robin at 20240816
This commit is contained in:
parent
d4cff8cc01
commit
5abd6883d4
|
@ -45,6 +45,8 @@ type ApiListExtVO struct {
|
|||
Zones []*dbstruct.Zone `json:"zones" bson:"zones"`
|
||||
IsActiveWithinAWeek *int64 `json:"is_active_within_a_week"` // 7日内空间是否活跃
|
||||
DaysElapsedSinceTheLastZonesUpdate *int64 `json:"days_elapsed_since_the_last_zones_update"` // 空间最后活跃时间距离现在时间跨度
|
||||
|
||||
Score float64 `json:"score"`
|
||||
}
|
||||
|
||||
func (vo *ApiListExtVO) GetMid() int64 {
|
||||
|
|
|
@ -174,7 +174,7 @@ func (es *ElasticSearch) GetStreamerAcctListFuzzilyByUserId(ctx *gin.Context, re
|
|||
return
|
||||
}
|
||||
|
||||
func (es *ElasticSearch) FilterStreamerAcctList(ctx *gin.Context, req *streameracctproto.OpFilterReq) (list []*dbstruct.EsStreamerAcct, scorelist []float64, fullscore int64, err error) {
|
||||
func (es *ElasticSearch) FilterStreamerAcctList(ctx *gin.Context, req *streameracctproto.OpFilterReq) (list []*dbstruct.EsStreamerAcct, scorelist []float64, fullscore float64, err error) {
|
||||
|
||||
list = make([]*dbstruct.EsStreamerAcct, 0)
|
||||
scorelist = make([]float64, 0)
|
||||
|
@ -242,6 +242,9 @@ func (es *ElasticSearch) FilterStreamerAcctList(ctx *gin.Context, req *streamera
|
|||
// 按得分倒序排列
|
||||
sortClause := elastic.NewScoreSort().Desc()
|
||||
|
||||
source, _ := funcScoreQuery.Source()
|
||||
logger.Info(util.ToJson(source))
|
||||
|
||||
res, err := es.clientMix.Search(es.getIndexStreamerAcct()).Query(funcScoreQuery).From(req.Offset).Size(req.Limit).SortBy(sortClause).Do(ctx)
|
||||
if err != nil {
|
||||
logger.Error("Search %v fail, err: %v", IndexStreamerAcct, err)
|
||||
|
|
|
@ -1786,7 +1786,7 @@ func (s *Service) ApiFilterStreamer(ctx *gin.Context, req *streamerproto.ApiFilt
|
|||
}
|
||||
|
||||
//1.从主播用户表中模糊匹配所有主播信息的用户侧数据,按mid正序排序
|
||||
streameraccts, err := _DefaultStreamerAcct.OpFilterStreamerAcct(ctx, &streameracctproto.OpFilterReq{
|
||||
streameraccts, scores, fullscore, err := _DefaultStreamerAcct.OpFilterStreamerAcct(ctx, &streameracctproto.OpFilterReq{
|
||||
Age: req.Age,
|
||||
Fans: req.Fans,
|
||||
Height: req.Height,
|
||||
|
@ -1818,9 +1818,15 @@ func (s *Service) ApiFilterStreamer(ctx *gin.Context, req *streamerproto.ApiFilt
|
|||
return
|
||||
}
|
||||
streamerlist = make([]*streamerproto.ApiListExtVO, 0)
|
||||
for _, mid := range mids {
|
||||
recommlist = make([]*streamerproto.ApiListExtVO, 0)
|
||||
for i, mid := range mids {
|
||||
vo, _ := mp[mid].(*streamerproto.ApiListExtVO)
|
||||
streamerlist = append(streamerlist, vo)
|
||||
vo.Score = scores[i]
|
||||
if scores[i] < fullscore {
|
||||
recommlist = append(recommlist, vo)
|
||||
} else {
|
||||
streamerlist = append(streamerlist, vo)
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
|
|
|
@ -75,11 +75,11 @@ func (p *StreamerAcct) OpListStreamerAcctFuzzilyByName(ctx *gin.Context, req *st
|
|||
return list, nil
|
||||
}
|
||||
|
||||
func (p *StreamerAcct) OpFilterStreamerAcct(ctx *gin.Context, req *streameracctproto.OpFilterReq) ([]*dbstruct.EsStreamerAcct, error) {
|
||||
list, err := p.store.FilterStreamerAcctList(ctx, req)
|
||||
func (p *StreamerAcct) OpFilterStreamerAcct(ctx *gin.Context, req *streameracctproto.OpFilterReq) ([]*dbstruct.EsStreamerAcct, []float64, float64, error) {
|
||||
list, scorelist, fullscore, err := p.store.FilterStreamerAcctList(ctx, req)
|
||||
if err != nil {
|
||||
logger.Error("FilterStreamerAcctList fail, err: %v", err)
|
||||
return nil, err
|
||||
return nil, nil, 0, err
|
||||
}
|
||||
return list, nil
|
||||
return list, scorelist, fullscore, nil
|
||||
}
|
||||
|
|
|
@ -378,7 +378,7 @@ func GetLastLessOrEqualForFloat64(arr []float64, target float64) int {
|
|||
type Int64Filter struct {
|
||||
LowerBound *int64 `json:"lower_bound" bson:"lower_bound"`
|
||||
UpperBound *int64 `json:"upper_bound" bson:"upper_bound"`
|
||||
Scale int64 `json:"scale" bson:"scale"`
|
||||
Scale float64 `json:"scale" bson:"scale"`
|
||||
Decay float64 `json:"decay" bson:"decay"`
|
||||
Weight float64 `json:"weight" bson:"weight"`
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue