Merge branch 'dev' into alpha

pull/398/head
Michael Li 10 months ago
commit ec5ab88b86
No known key found for this signature in database

@ -17,11 +17,9 @@ type tweetMetricSrvA struct {
func (s *tweetMetricSrvA) UpdateRankScore(metric *cs.TweetMetric) error {
return s.db.Transaction(func(tx *gorm.DB) (err error) {
postMetric := &dbr.PostMetric{}
postMetric := &dbr.PostMetric{PostId: metric.PostId}
db := s.db.Model(postMetric).Where("post_id=?", metric.PostId)
if err = db.First(postMetric).Error; err != nil {
return
}
db.First(postMetric)
postMetric.RankScore = metric.RankScore(postMetric.MotivationFactor)
err = db.Save(postMetric).Error
return
@ -30,7 +28,7 @@ func (s *tweetMetricSrvA) UpdateRankScore(metric *cs.TweetMetric) error {
}
func (s *tweetMetricSrvA) AddTweetMetric(postId int64) (err error) {
_, err = (&dbr.PostMetric{}).Create(s.db)
_, err = (&dbr.PostMetric{PostId: postId}).Create(s.db)
return
}

@ -438,7 +438,7 @@ func (s *tweetSrv) ListIndexNewestTweets(limit, offset int) (res []*ms.Post, tot
}
func (s *tweetSrv) ListIndexHotsTweets(limit, offset int) (res []*ms.Post, total int64, err error) {
db := s.db.Table(_post_).Joins(fmt.Sprintf("JOIN %s metric ON %s.id=metric.post_id", _post_metric_, _post_)).Where("visibility >= ?", cs.TweetVisitPublic)
db := s.db.Table(_post_).Joins(fmt.Sprintf("LEFT JOIN %s metric ON %s.id=metric.post_id", _post_metric_, _post_)).Where("visibility >= ?", cs.TweetVisitPublic)
if err = db.Count(&total).Error; err != nil {
return
}

Loading…
Cancel
Save