fix(ranking): When the ranking user's reputation or vote is less than 0, this user will not be displayed

This commit is contained in:
LinkinStar 2022-12-14 10:14:15 +08:00
parent 47140f7749
commit 3c7bcf006f
1 changed files with 10 additions and 4 deletions

View File

@ -571,21 +571,21 @@ func (us *UserService) UserRanking(ctx context.Context) (resp *schema.UserRankin
// get most reputation users
rankStat, rankStatUserIDs, err := us.getActivityUserRankStat(ctx, startTime, endTime, limit, userIDExist)
if err != nil {
return resp, nil
return nil, err
}
userIDs = append(userIDs, rankStatUserIDs...)
// get most vote users
voteStat, voteStatUserIDs, err := us.getActivityUserVoteStat(ctx, startTime, endTime, limit, userIDExist)
if err != nil {
return resp, nil
return nil, err
}
userIDs = append(userIDs, voteStatUserIDs...)
// get all staff members
userRoleRels, staffUserIDs, err := us.getStaff(ctx, userIDExist)
if err != nil {
return resp, nil
return nil, err
}
userIDs = append(userIDs, staffUserIDs...)
@ -623,7 +623,7 @@ func (us *UserService) getActivityUserVoteStat(ctx context.Context, startTime, e
return nil, nil, err
}
for _, stat := range voteStat {
if stat.VoteCount == 0 {
if stat.VoteCount <= 0 {
continue
}
if userIDExist[stat.UserID] {
@ -679,6 +679,9 @@ func (us *UserService) warpStatRankingResp(
Staffs: make([]*schema.UserRankingSimpleInfo, 0),
}
for _, stat := range rankStat {
if stat.Rank <= 0 {
continue
}
if userInfo := userInfoMapping[stat.UserID]; userInfo != nil {
resp.UsersWithTheMostReputation = append(resp.UsersWithTheMostReputation, &schema.UserRankingSimpleInfo{
Username: userInfo.Username,
@ -689,6 +692,9 @@ func (us *UserService) warpStatRankingResp(
}
}
for _, stat := range voteStat {
if stat.VoteCount <= 0 {
continue
}
if userInfo := userInfoMapping[stat.UserID]; userInfo != nil {
resp.UsersWithTheMostVote = append(resp.UsersWithTheMostVote, &schema.UserRankingSimpleInfo{
Username: userInfo.Username,