feat: 按原型更新商务明细与游戏分析并清理临时资料
This commit is contained in:
@@ -47,7 +47,7 @@ type ServerOption struct {
|
||||
}
|
||||
type ServerAnalysisRepo interface {
|
||||
Aggregate(context.Context, AnalyticsScope, ServerAnalysisFilter) (*ServerAnalysisData, error)
|
||||
Servers(context.Context, []string, []string, string, int) ([]*ServerOption, error)
|
||||
Servers(context.Context, UserScope, []string, []string, string, int) ([]*ServerOption, error)
|
||||
}
|
||||
type ServerAnalysisUsecase struct {
|
||||
repo ServerAnalysisRepo
|
||||
@@ -60,9 +60,12 @@ func NewServerAnalysisUsecase(repo ServerAnalysisRepo, accounts *AccountUsecase,
|
||||
return &ServerAnalysisUsecase{repo: repo, accounts: accounts, preferences: preferences, now: time.Now}
|
||||
}
|
||||
func (uc *ServerAnalysisUsecase) Servers(ctx context.Context, sources, games []string, keyword string, limit int) ([]*ServerOption, error) {
|
||||
if _, _, err := uc.accounts.actor(ctx); err != nil {
|
||||
actor, account, err := uc.accounts.actor(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
viewer := portraitUserScope(account)
|
||||
viewer.All = actor.AuthorityID == 888
|
||||
if len(games) == 0 {
|
||||
return nil, ErrServerAnalysisGame
|
||||
}
|
||||
@@ -72,7 +75,7 @@ func (uc *ServerAnalysisUsecase) Servers(ctx context.Context, sources, games []s
|
||||
if limit > 100 {
|
||||
limit = 100000
|
||||
}
|
||||
return uc.repo.Servers(ctx, sources, games, strings.TrimSpace(keyword), limit)
|
||||
return uc.repo.Servers(ctx, viewer, sources, games, strings.TrimSpace(keyword), limit)
|
||||
}
|
||||
func (uc *ServerAnalysisUsecase) List(ctx context.Context, f ServerAnalysisFilter, page, size int) (*ServerAnalysisPage, error) {
|
||||
actor, account, err := uc.accounts.actor(ctx)
|
||||
@@ -151,6 +154,19 @@ func (uc *ServerAnalysisUsecase) List(ctx context.Context, f ServerAnalysisFilte
|
||||
return out, nil
|
||||
}
|
||||
func sortServerAnalysis(rows []*ServerAnalysisRow, field string, ascending bool) error {
|
||||
if field == "" {
|
||||
sort.SliceStable(rows, func(i, j int) bool {
|
||||
a, b := rows[i], rows[j]
|
||||
if a.SourceDB != b.SourceDB {
|
||||
return a.SourceDB < b.SourceDB
|
||||
}
|
||||
if a.GameID != b.GameID {
|
||||
return a.GameID < b.GameID
|
||||
}
|
||||
return a.ServerNum < b.ServerNum
|
||||
})
|
||||
return nil
|
||||
}
|
||||
values := map[*ServerAnalysisRow]*big.Rat{}
|
||||
for _, row := range rows {
|
||||
var n *big.Rat
|
||||
|
||||
Reference in New Issue
Block a user