feat: 按原型更新商务明细与游戏分析并清理临时资料
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
func TestServerAnalysisStorageScopeSnapshotAndPreference(t *testing.T) {
|
||||
db, _ := prepareChannels(t)
|
||||
for _, sql := range []string{
|
||||
"INSERT INTO tab_promote_apply VALUES('hw',100,1,1)",
|
||||
"CREATE TABLE tab_game_server(id INTEGER,source_db TEXT,game_id INTEGER,server_num TEXT,server_name TEXT,start_time INTEGER)",
|
||||
"INSERT INTO tab_game_server VALUES(1,'lx',1,'001','龙翔一区',100),(2,'hw',1,'001','汇玩一区',200),(3,'lx',2,'001','游戏乙一区',300),(4,'yq',1,'001','无权区服',400)",
|
||||
"CREATE TABLE tab_sw_report_server_day(source_db TEXT,game_id INTEGER,game_name TEXT,promote_id INTEGER,server_num TEXT,stat_date DATE,dedup_mode INTEGER,total_pay DECIMAL(20,2))",
|
||||
@@ -68,7 +69,7 @@ func TestServerAnalysisStorageScopeSnapshotAndPreference(t *testing.T) {
|
||||
if err != nil || len(p.Rows) != 1 {
|
||||
t.Fatal("区服编号筛选错误")
|
||||
}
|
||||
options, err := r.Servers(ctx, []string{"lx"}, []string{"游戏甲"}, "一区", 50)
|
||||
options, err := r.Servers(ctx, s.Viewer, []string{"lx"}, []string{"游戏甲"}, "一区", 50)
|
||||
if err != nil || len(options) != 1 || options[0].Number != "001" || options[0].Name != "龙翔一区" {
|
||||
t.Fatal("选项应按当前游戏名、同平台游戏关联及区服名称筛选")
|
||||
}
|
||||
@@ -77,6 +78,18 @@ func TestServerAnalysisStorageScopeSnapshotAndPreference(t *testing.T) {
|
||||
if err != nil || len(p.Rows) != 0 {
|
||||
t.Fatal("报表必须按快照游戏名筛选")
|
||||
}
|
||||
if err := db.Exec("UPDATE tab_promote_apply SET status=0 WHERE source_db='lx' AND game_id=1").Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
options, err = r.Servers(ctx, s.Viewer, []string{"lx"}, []string{"游戏甲"}, "", 50)
|
||||
if err != nil || len(options) != 0 {
|
||||
t.Fatal("没有有效申请的游戏不能获取区服选项")
|
||||
}
|
||||
f.GameNames = []string{"历史游戏"}
|
||||
p, err = r.Aggregate(ctx, s, f)
|
||||
if err != nil || len(p.Rows) != 0 {
|
||||
t.Fatal("直接传入未申请游戏也不能获取区服数据")
|
||||
}
|
||||
if err := db.Exec("DROP TABLE tab_sw_report_server_day_key").Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -89,6 +102,10 @@ func TestServerAnalysisStorageScopeSnapshotAndPreference(t *testing.T) {
|
||||
func TestServerOptionsPreservePlatformFilterAndDoNotDuplicateMatches(t *testing.T) {
|
||||
db := openTestDB(t)
|
||||
for _, sql := range []string{
|
||||
"CREATE TABLE tab_promote(id INTEGER,source_db TEXT)",
|
||||
"INSERT INTO tab_promote VALUES(100,'lx'),(100,'hw')",
|
||||
"CREATE TABLE tab_promote_apply(source_db TEXT,promote_id INTEGER,game_id INTEGER,status INTEGER)",
|
||||
"INSERT INTO tab_promote_apply VALUES('lx',100,1,1),('lx',100,2,1),('hw',100,1,1)",
|
||||
"CREATE TABLE tab_game(id INTEGER,source_db TEXT,game_name TEXT)",
|
||||
"INSERT INTO tab_game VALUES(1,'lx','甲'),(1,'lx','甲'),(1,'hw','乙'),(2,'lx','乙')",
|
||||
"CREATE TABLE tab_game_server(id INTEGER,source_db TEXT,game_id INTEGER,server_num TEXT,server_name TEXT,start_time INTEGER)",
|
||||
@@ -99,15 +116,15 @@ func TestServerOptionsPreservePlatformFilterAndDoNotDuplicateMatches(t *testing.
|
||||
}
|
||||
}
|
||||
repo := NewServerAnalysisRepo(testData{db})
|
||||
rows, err := repo.Servers(context.Background(), nil, []string{"甲"}, "", 100)
|
||||
rows, err := repo.Servers(context.Background(), business.UserScope{All: true}, nil, []string{"甲"}, "", 100)
|
||||
if err != nil || len(rows) != 2 || rows[0].Name != "一区" || rows[1].Number != "002" {
|
||||
t.Fatalf("相同游戏资料不能扩增区服,异平台同号不能匹配: %+v %v", rows, err)
|
||||
}
|
||||
rows, err = repo.Servers(context.Background(), []string{"lx"}, []string{"甲", "乙"}, "区", 1)
|
||||
rows, err = repo.Servers(context.Background(), business.UserScope{All: true}, []string{"lx"}, []string{"甲", "乙"}, "区", 1)
|
||||
if err != nil || len(rows) != 1 || rows[0].Name != "一区" {
|
||||
t.Fatalf("名称筛选、排序或数量限制改变: %+v %v", rows, err)
|
||||
}
|
||||
rows, err = repo.Servers(context.Background(), []string{"hw"}, []string{"甲"}, "", 100)
|
||||
rows, err = repo.Servers(context.Background(), business.UserScope{All: true}, []string{"hw"}, []string{"甲"}, "", 100)
|
||||
if err != nil || len(rows) != 0 {
|
||||
t.Fatalf("平台筛选被忽略: %+v %v", rows, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user