Skip to content

Commit 606e21c

Browse files
authored
Merge pull request #525 from penguin-statistics/dev
Release v3.14.12
2 parents 570c91f + 22a49f1 commit 606e21c

File tree

7 files changed

+30
-26
lines changed

7 files changed

+30
-26
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.21.4-alpine AS base
1+
FROM golang:1.21.6-alpine AS base
22
WORKDIR /app
33

44
# builder

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ require (
6060
go.opentelemetry.io/otel/sdk v1.16.0
6161
go.uber.org/fx v1.19.2
6262
golang.org/x/exp v0.0.0-20220823124025-807a23277127
63-
golang.org/x/mod v0.9.0
63+
golang.org/x/mod v0.14.0
6464
golang.org/x/sync v0.5.0
6565
golang.org/x/text v0.14.0
6666
google.golang.org/protobuf v1.30.0
@@ -162,7 +162,7 @@ require (
162162
golang.org/x/crypto v0.14.0 // indirect
163163
golang.org/x/net v0.17.0 // indirect
164164
golang.org/x/sys v0.13.0 // indirect
165-
golang.org/x/tools v0.7.0 // indirect
165+
golang.org/x/tools v0.13.0 // indirect
166166
gopkg.in/yaml.v3 v3.0.1 // indirect
167167
mellium.im/sasl v0.3.1 // indirect
168168
)

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,8 @@ golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
636636
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
637637
golang.org/x/mod v0.9.0 h1:KENHtAZL2y3NLMYZeHY9DW8HW8V+kQyJsY/V9JlKvCs=
638638
golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
639+
golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0=
640+
golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
639641
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
640642
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
641643
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@@ -839,6 +841,8 @@ golang.org/x/tools v0.5.0/go.mod h1:N+Kgy78s5I24c24dU8OfWNEotWjutIs8SnJvn5IDq+k=
839841
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
840842
golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4=
841843
golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s=
844+
golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ=
845+
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
842846
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
843847
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
844848
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

internal/model/cache/caches.go

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package cache
22

33
import (
4-
"context"
54
"sync"
65
"time"
76

@@ -11,14 +10,14 @@ import (
1110
"exusiai.dev/backend-next/internal/model"
1211
modelv2 "exusiai.dev/backend-next/internal/model/v2"
1312
"exusiai.dev/backend-next/internal/pkg/cache"
14-
"exusiai.dev/backend-next/internal/repo"
1513
)
1614

1715
type Flusher func() error
1816

1917
var (
2018
AccountByID *cache.Set[model.Account]
2119
AccountByPenguinID *cache.Set[model.Account]
20+
AccountExistence *cache.Set[int]
2221

2322
ItemDropSetByStageIDAndRangeID *cache.Set[[]int]
2423
ItemDropSetByStageIdAndTimeRange *cache.Set[[]int]
@@ -73,18 +72,15 @@ var (
7372

7473
LastModifiedTime *cache.Set[time.Time]
7574

76-
Properties map[string]string
77-
7875
once sync.Once
7976

8077
SetMap map[string]Flusher
8178
SingularFlusherMap map[string]Flusher
8279
)
8380

84-
func Initialize(propertyRepo *repo.Property) {
81+
func Initialize() {
8582
once.Do(func() {
8683
initializeCaches()
87-
populateProperties(propertyRepo)
8884
})
8985
}
9086

@@ -116,9 +112,11 @@ func initializeCaches() {
116112
// account
117113
AccountByID = cache.NewSet[model.Account]("account#accountId")
118114
AccountByPenguinID = cache.NewSet[model.Account]("account#penguinId")
115+
AccountExistence = cache.NewSet[int]("accountExistence#accountId")
119116

120117
SetMap["account#accountId"] = AccountByID.Flush
121118
SetMap["account#penguinId"] = AccountByPenguinID.Flush
119+
SetMap["accountExistence#accountId"] = AccountExistence.Flush
122120

123121
// drop_info
124122
ItemDropSetByStageIDAndRangeID = cache.NewSet[[]int]("itemDropSet#server|stageId|rangeId")
@@ -239,15 +237,3 @@ func initializeCaches() {
239237

240238
SetMap["lastModifiedTime#key"] = LastModifiedTime.Flush
241239
}
242-
243-
func populateProperties(repo *repo.Property) {
244-
Properties = make(map[string]string)
245-
properties, err := repo.GetProperties(context.Background())
246-
if err != nil {
247-
panic(err)
248-
}
249-
250-
for _, property := range properties {
251-
Properties[property.Key] = property.Value
252-
}
253-
}

internal/repo/account.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ package repo
22

33
import (
44
"context"
5+
"strconv"
56
"time"
67

78
"github.com/rs/zerolog/log"
89
"github.com/uptrace/bun"
910

1011
"exusiai.dev/backend-next/internal/model"
12+
"exusiai.dev/backend-next/internal/model/cache"
1113
"exusiai.dev/backend-next/internal/pkg/pgerr"
1214
"exusiai.dev/backend-next/internal/pkg/pgid"
1315
"exusiai.dev/backend-next/internal/repo/selector"
@@ -74,12 +76,23 @@ func (r *Account) GetAccountByPenguinId(ctx context.Context, penguinId string) (
7476
}
7577

7678
func (r *Account) IsAccountExistWithId(ctx context.Context, accountId int) bool {
79+
var exist int
80+
err := cache.AccountExistence.Get(strconv.Itoa(accountId), &exist)
81+
if err == nil {
82+
return exist == 1
83+
}
7784
account, err := r.sel.SelectOne(ctx, func(q *bun.SelectQuery) *bun.SelectQuery {
7885
return q.Column("account_id").Where("account_id = ?", accountId)
7986
})
8087
if err != nil {
8188
return false
8289
}
8390

84-
return account != nil
91+
exists := account != nil
92+
93+
if exists {
94+
cache.AccountExistence.Set(strconv.Itoa(account.AccountID), 1, time.Hour*24)
95+
}
96+
97+
return exists
8598
}

internal/repo/drop_report_extra.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,16 @@ func (c *DropReportExtra) DeleteDropReportExtrasForArchive(ctx context.Context,
7373
func (c *DropReportExtra) IsDropReportExtraMD5Exist(ctx context.Context, md5 string) bool {
7474
var dropReportExtra model.DropReportExtra
7575

76-
count, err := c.db.NewSelect().
76+
err := c.db.NewSelect().
7777
Model(&dropReportExtra).
7878
Where("md5 = ?", md5).
79-
Count(ctx)
79+
Limit(1).
80+
Scan(ctx)
8081
if err != nil {
8182
return false
8283
}
8384

84-
return count > 0
85+
return true
8586
}
8687

8788
func (r *DropReportExtra) CreateDropReportExtra(ctx context.Context, tx bun.Tx, report *model.DropReportExtra) error {

internal/util/reportverifs/verify_md5.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ package reportverifs
33
import (
44
"context"
55

6+
"exusiai.dev/gommon/constant"
67
"github.com/pkg/errors"
78

89
"exusiai.dev/backend-next/internal/model/types"
910
"exusiai.dev/backend-next/internal/repo"
10-
"exusiai.dev/gommon/constant"
1111
)
1212

1313
var ErrMD5Conflict = errors.New("report with specified md5 has already existed")

0 commit comments

Comments
 (0)