diff --git a/internal/dao/jinzhu/metrics.go b/internal/dao/jinzhu/metrics.go index 175ad6bc..5df75fe9 100644 --- a/internal/dao/jinzhu/metrics.go +++ b/internal/dao/jinzhu/metrics.go @@ -5,6 +5,8 @@ package jinzhu import ( + "time" + "github.com/rocboss/paopao-ce/internal/core" "github.com/rocboss/paopao-ce/internal/core/cs" "github.com/rocboss/paopao-ce/internal/dao/jinzhu/dbr" @@ -71,6 +73,7 @@ func (s *userMetricSrvA) UpdateUserMetric(userId int64, action uint8) (err error UserId: userId, } } + metric.LatestTrendsOn = time.Now().Unix() switch action { case cs.MetricActionCreateTweet: metric.TweetsCount++ diff --git a/internal/dao/jinzhu/trends.go b/internal/dao/jinzhu/trends.go index e4fa8061..2d4aff4b 100644 --- a/internal/dao/jinzhu/trends.go +++ b/internal/dao/jinzhu/trends.go @@ -27,7 +27,7 @@ func (s *trendsSrvA) GetIndexTrends(userId int64, limit int, offset int) (res [] if offset >= 0 && limit > 0 { db = db.Limit(limit).Offset(offset) } - if err = db.Order("r.style ASC").Select("username", "nickname", "avatar").Find(&res).Error; err == nil { + if err = db.Order("r.style ASC, m.latest_trends_on DESC").Select("username", "nickname", "avatar").Find(&res).Error; err == nil { res = cs.DistinctTrends(res) } return