diff --git a/app/mix/service/utilservice.go b/app/mix/service/utilservice.go index b933909c..f7c01bc5 100644 --- a/app/mix/service/utilservice.go +++ b/app/mix/service/utilservice.go @@ -827,10 +827,10 @@ func (s *Service) utilGetStreamerRecommlistOffsetAndBottomeFlag(ctx *gin.Context func (s *Service) utilGetStreamerRecommListVO(ctx *gin.Context, recommlist []int64, mid int64, opType int64) (recommStreamerList []*streamerproto.ApiListExtVO, err error) { // 获取用户游标 offset := int64(0) - recommListLength := len(recommlist) - upperBound := recommListLength + recommListLength := int64(len(recommlist)) + upperBound := int64(consts.StreamerRecommThroughput) - offset, bottomFlag, err := s.utilGetStreamerRecommlistOffsetAndBottomeFlag(ctx, int64(recommListLength), mid, opType) + offset, bottomFlag, err := s.utilGetStreamerRecommlistOffsetAndBottomeFlag(ctx, recommListLength, mid, opType) if err != nil { logger.Error("utilGetStreamerRecommlistOffsetAndBottomeFlag fail, err: %v", err) return @@ -839,13 +839,15 @@ func (s *Service) utilGetStreamerRecommListVO(ctx *gin.Context, recommlist []int return make([]*streamerproto.ApiListExtVO, 0), nil } - if consts.StreamerRecommThroughput < recommListLength { - upperBound = consts.StreamerRecommThroughput + surplusVolume := recommListLength - offset + + if surplusVolume < consts.StreamerRecommThroughput { + upperBound = surplusVolume } // 根据用户游标查询得到结果 midList := make([]int64, 0) - for i := 0; i < upperBound; i++ { + for i := int64(0); i < upperBound; i++ { index := (offset + int64(i)) % int64(recommListLength) midList = append(midList, recommlist[index]) } @@ -1107,7 +1109,7 @@ func (s *Service) utilGetMomentRecommListIds(ctx *gin.Context, mid int64, opType // 获取用户游标 offset := int64(0) - upperBound := recommListLength + upperBound := throughput // 获取游标和是否已触底标志 offset, bottomFlag, err := s.utilGetMomentRecommlistOffsetAndBottomeFlag(ctx, mid, opType, recommListLength, throughput) @@ -1119,8 +1121,10 @@ func (s *Service) utilGetMomentRecommListIds(ctx *gin.Context, mid int64, opType return make([]int64, 0), nil } - if throughput < recommListLength { - upperBound = throughput + surplusVolume := recommListLength - offset + + if surplusVolume < throughput { + upperBound = surplusVolume } // 根据用户游标得到待查询ids