Skip to content

Commit

Permalink
fixed follow topics number more by give number error
Browse files Browse the repository at this point in the history
  • Loading branch information
alimy committed Apr 20, 2023
1 parent 32b5b68 commit 96ac9d7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion internal/dao/jinzhu/topics.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@ func (s *topicServant) GetFollowTags(userId int64, limit int, offset int) ([]*co
return nil, nil
}
userTopics := []*topicInfo{}
err := s.db.Model(&dbr.TopicUser{}).Where("user_id=?", userId).Order("is_top DESC").Find(&userTopics).Error
err := s.db.Model(&dbr.TopicUser{}).
Where("user_id=?", userId).
Order("is_top DESC").
Limit(limit).
Offset(offset).
Find(&userTopics).Error
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions internal/servants/web/loose.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,12 @@ func (s *looseSrv) TopicList(req *web.TopicListReq) (*web.TopicListResp, mir.Err
tags, err = s.Ds.GetFollowTags(req.Uid, num, 0)
case web.TagTypeHotExtral:
extralNum := req.ExtralNum
if extralNum == 0 {
if extralNum <= 0 {
extralNum = num
}
tags, err = s.Ds.GetHotTags(req.Uid, num, 0)
if err == nil {
extralTags, err = s.Ds.GetFollowTags(req.Uid, num, 0)
extralTags, err = s.Ds.GetFollowTags(req.Uid, extralNum, 0)
}
default:
// TODO: return good error
Expand Down

0 comments on commit 96ac9d7

Please sign in to comment.