From 308ef2687c086e239e39e66d309eb06819cba32f Mon Sep 17 00:00:00 2001 From: Michael Li Date: Sat, 7 Oct 2023 17:57:28 +0800 Subject: [PATCH 1/2] optimize get index trends info logic --- internal/dao/jinzhu/metrics.go | 3 +++ internal/dao/jinzhu/trends.go | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) 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 From 8a01fde15c465a827cf9cc01cbb969b0f5000202 Mon Sep 17 00:00:00 2001 From: Michael Li Date: Sat, 7 Oct 2023 20:02:55 +0800 Subject: [PATCH 2/2] update ci configure --- .github/workflows/go.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 66a46ea3..f3c274dc 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -47,7 +47,7 @@ jobs: name: Test strategy: matrix: - go-version: [ 1.20.x, 1.21.x ] + go-version: [ 1.21.x ] platform: [ ubuntu-latest, macos-latest ] runs-on: ${{ matrix.platform }} steps: @@ -66,7 +66,7 @@ jobs: name: TestOnWindows strategy: matrix: - go-version: [ 1.20.x, 1.21.x ] + go-version: [ 1.21.x ] platform: [ windows-latest ] runs-on: ${{ matrix.platform }} steps: