diff --git a/internal/core/cs/metrics.go b/internal/core/cs/metrics.go index 01257f4f..169126d3 100644 --- a/internal/core/cs/metrics.go +++ b/internal/core/cs/metrics.go @@ -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) } diff --git a/internal/dao/jinzhu/metrics.go b/internal/dao/jinzhu/metrics.go index c39886f4..f73fad5c 100644 --- a/internal/dao/jinzhu/metrics.go +++ b/internal/dao/jinzhu/metrics.go @@ -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 }