fix: 区服报表复用批量游戏权限校验
This commit is contained in:
@@ -29,6 +29,25 @@ func approvedGamesQuery(db *gorm.DB, viewer business.UserScope, sources []string
|
||||
return q
|
||||
}
|
||||
|
||||
// Check authorization for the distinct games present in an aggregated report.
|
||||
func approvedGameKeys(db *gorm.DB, viewer business.UserScope, sources []string, keys []business.AnalyticsKey) (map[business.AnalyticsKey]bool, error) {
|
||||
allowed := map[business.AnalyticsKey]bool{}
|
||||
for start := 0; start < len(keys); start += 300 {
|
||||
var games []struct {
|
||||
SourceDB string `gorm:"column:source_db"`
|
||||
ID int64
|
||||
}
|
||||
q := approvedGamesQuery(db, viewer, sources).Where("(g.source_db,g.id) IN ?", analyticsPairs(keys[start:min(start+300, len(keys))]))
|
||||
if err := q.Select("g.source_db,g.id").Scan(&games).Error; err != nil {
|
||||
return nil, business.ErrStorage
|
||||
}
|
||||
for _, game := range games {
|
||||
allowed[business.AnalyticsKey{SourceDB: game.SourceDB, ID: game.ID}] = true
|
||||
}
|
||||
}
|
||||
return allowed, nil
|
||||
}
|
||||
|
||||
func migrateApprovedGameIndexes(db *gorm.DB) error {
|
||||
return migrateQueryIndexes(db, []businessQueryIndex{
|
||||
{"tab_promote_apply", "idx_sw_apply_game_scope", []string{"game_id", "source_db", "status", "promote_id"}},
|
||||
|
||||
Reference in New Issue
Block a user