修复除以0

pull/701/head
miaowuawa 1 year ago
parent 0b5a23d39b
commit 5c2652773b

@ -20,6 +20,9 @@ type TweetMetric struct {
}
func (m *TweetMetric) RankScore(motivationFactor int) int64 {
if m.DecayFactor == 0 {
return 0
}
return int64(m.IncentiveScore * motivationFactor / m.DecayFactor)
}

@ -43,7 +43,7 @@ func (s *tweetMetricSrvA) UpdateTweetMetric(metric *cs.TweetMetric) error {
}
func (s *tweetMetricSrvA) AddTweetMetric(postId int64) (err error) {
_, err = (&dbr.PostMetric{PostId: postId}).Create(s.db)
_, err = (&dbr.PostMetric{PostId: postId, DecayFactor: 100}).Create(s.db)
return
}
@ -64,7 +64,7 @@ func (s *commentMetricSrvA) UpdateCommentMetric(metric *cs.CommentMetric) error
}
func (s *commentMetricSrvA) AddCommentMetric(commentId int64) (err error) {
_, err = (&dbr.CommentMetric{CommentId: commentId}).Create(s.db)
_, err = (&dbr.CommentMetric{CommentId: commentId, DecayFactor: 100}).Create(s.db)
return
}

Loading…
Cancel
Save