From 5c2652773b6250eea06d88cd0b9cbd0ffae852d4 Mon Sep 17 00:00:00 2001 From: miaowuawa <2484667023@qq.com> Date: Wed, 16 Jul 2025 22:44:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=99=A4=E4=BB=A50?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/core/cs/metrics.go | 3 +++ internal/dao/jinzhu/metrics.go | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) 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 }