by Robin at 20240816

This commit is contained in:
Leufolium 2024-08-16 07:06:12 +08:00
parent d4cff8cc01
commit 5abd6883d4
5 changed files with 20 additions and 9 deletions

View File

@ -45,6 +45,8 @@ type ApiListExtVO struct {
Zones []*dbstruct.Zone `json:"zones" bson:"zones"` Zones []*dbstruct.Zone `json:"zones" bson:"zones"`
IsActiveWithinAWeek *int64 `json:"is_active_within_a_week"` // 7日内空间是否活跃 IsActiveWithinAWeek *int64 `json:"is_active_within_a_week"` // 7日内空间是否活跃
DaysElapsedSinceTheLastZonesUpdate *int64 `json:"days_elapsed_since_the_last_zones_update"` // 空间最后活跃时间距离现在时间跨度 DaysElapsedSinceTheLastZonesUpdate *int64 `json:"days_elapsed_since_the_last_zones_update"` // 空间最后活跃时间距离现在时间跨度
Score float64 `json:"score"`
} }
func (vo *ApiListExtVO) GetMid() int64 { func (vo *ApiListExtVO) GetMid() int64 {

View File

@ -174,7 +174,7 @@ func (es *ElasticSearch) GetStreamerAcctListFuzzilyByUserId(ctx *gin.Context, re
return 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) list = make([]*dbstruct.EsStreamerAcct, 0)
scorelist = make([]float64, 0) scorelist = make([]float64, 0)
@ -242,6 +242,9 @@ func (es *ElasticSearch) FilterStreamerAcctList(ctx *gin.Context, req *streamera
// 按得分倒序排列 // 按得分倒序排列
sortClause := elastic.NewScoreSort().Desc() 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) res, err := es.clientMix.Search(es.getIndexStreamerAcct()).Query(funcScoreQuery).From(req.Offset).Size(req.Limit).SortBy(sortClause).Do(ctx)
if err != nil { if err != nil {
logger.Error("Search %v fail, err: %v", IndexStreamerAcct, err) logger.Error("Search %v fail, err: %v", IndexStreamerAcct, err)

View File

@ -1786,7 +1786,7 @@ func (s *Service) ApiFilterStreamer(ctx *gin.Context, req *streamerproto.ApiFilt
} }
//1.从主播用户表中模糊匹配所有主播信息的用户侧数据按mid正序排序 //1.从主播用户表中模糊匹配所有主播信息的用户侧数据按mid正序排序
streameraccts, err := _DefaultStreamerAcct.OpFilterStreamerAcct(ctx, &streameracctproto.OpFilterReq{ streameraccts, scores, fullscore, err := _DefaultStreamerAcct.OpFilterStreamerAcct(ctx, &streameracctproto.OpFilterReq{
Age: req.Age, Age: req.Age,
Fans: req.Fans, Fans: req.Fans,
Height: req.Height, Height: req.Height,
@ -1818,9 +1818,15 @@ func (s *Service) ApiFilterStreamer(ctx *gin.Context, req *streamerproto.ApiFilt
return return
} }
streamerlist = make([]*streamerproto.ApiListExtVO, 0) streamerlist = make([]*streamerproto.ApiListExtVO, 0)
for _, mid := range mids { recommlist = make([]*streamerproto.ApiListExtVO, 0)
for i, mid := range mids {
vo, _ := mp[mid].(*streamerproto.ApiListExtVO) 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 return

View File

@ -75,11 +75,11 @@ func (p *StreamerAcct) OpListStreamerAcctFuzzilyByName(ctx *gin.Context, req *st
return list, nil return list, nil
} }
func (p *StreamerAcct) OpFilterStreamerAcct(ctx *gin.Context, req *streameracctproto.OpFilterReq) ([]*dbstruct.EsStreamerAcct, error) { func (p *StreamerAcct) OpFilterStreamerAcct(ctx *gin.Context, req *streameracctproto.OpFilterReq) ([]*dbstruct.EsStreamerAcct, []float64, float64, error) {
list, err := p.store.FilterStreamerAcctList(ctx, req) list, scorelist, fullscore, err := p.store.FilterStreamerAcctList(ctx, req)
if err != nil { if err != nil {
logger.Error("FilterStreamerAcctList fail, err: %v", err) logger.Error("FilterStreamerAcctList fail, err: %v", err)
return nil, err return nil, nil, 0, err
} }
return list, nil return list, scorelist, fullscore, nil
} }

View File

@ -378,7 +378,7 @@ func GetLastLessOrEqualForFloat64(arr []float64, target float64) int {
type Int64Filter struct { type Int64Filter struct {
LowerBound *int64 `json:"lower_bound" bson:"lower_bound"` LowerBound *int64 `json:"lower_bound" bson:"lower_bound"`
UpperBound *int64 `json:"upper_bound" bson:"upper_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"` Decay float64 `json:"decay" bson:"decay"`
Weight float64 `json:"weight" bson:"weight"` Weight float64 `json:"weight" bson:"weight"`
} }