Skip to content

Commit

Permalink
[fix] 部分反馈可能影响在app图库的展示
Browse files Browse the repository at this point in the history
  • Loading branch information
kyrie committed Feb 14, 2023
1 parent 195bddf commit 4abc242
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions internal/app/api/idl/bilibili_picture.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const (
Uncomfortable DynamicFeedback = 4 //不适宜的内容
)

var DynamicFeedbackVec = []DynamicFeedback{Default, IncorrectTags, OnPeriod}
var DynamicFeedbackMap = map[DynamicFeedback]struct{}{
Default: {},
Unrelated: {},
Expand Down
8 changes: 4 additions & 4 deletions internal/repository/bilibili_picture.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (impl *BilibiliPictureMysqlImpl) Latest(page, size, topicID int) (list []*i
err = conn.Where("pictures_num > 0").Select("dynamic_id,sent_at").
Order("sent_at DESC").
Offset(offset).
Limit(size).Preload("Pics", "feedback = ?", 0).Find(&list).Error
Limit(size).Preload("Pics", "feedback in (?)", idl.DynamicFeedbackVec).Find(&list).Error
if err != nil {
return nil, err
}
Expand All @@ -128,7 +128,7 @@ func (impl *BilibiliPictureMysqlImpl) Recommend(from, to time.Time, page, size,
Where("sent_at >= ? AND sent_at <= ? AND pictures_num > 0", from.Unix(), to.Unix()).
Order("favor DESC").
Offset(offset).
Limit(size).Preload("Pics", "feedback = ?", 0).Find(&list).Error
Limit(size).Preload("Pics", "feedback in (?)", idl.DynamicFeedbackVec).Find(&list).Error
if err != nil {
return nil, err
}
Expand All @@ -147,7 +147,7 @@ func (impl *BilibiliPictureMysqlImpl) Random(rand float64) (list []*idl.Bilibili
return nil, err
}
offset := math.Floor((pair.MaxId - pair.MinId) * rand)
err = conn.Where("id >= ? AND feedback = 0", uint64(pair.MinId+offset)).
err = conn.Where("id >= ? AND feedback in (?)", uint64(pair.MinId+offset), idl.DynamicFeedbackVec).
Select("id,dynamic_id,img_src,img_attr,verify").
Preload("Dynamic").Limit(5).Find(&list).Error
if err != nil {
Expand All @@ -172,7 +172,7 @@ func (impl *BilibiliPictureMysqlImpl) Verify(req idl.BilibiliPictureVerifyReq, d
if conn.Error != nil {
return conn.Error
}
if conn.RowsAffected == 0 || req.FeedBack == 0 {
if conn.RowsAffected == 0 || req.FeedBack == idl.Default || req.FeedBack == idl.IncorrectTags || req.FeedBack == idl.OnPeriod {
return nil
}
return _tx.Table(idl.BilibiliDynamic{}.TableName()).
Expand Down

0 comments on commit 4abc242

Please sign in to comment.