fix: include inactive channels in negative activity filters

This commit is contained in:
Yvan
2026-11-06 01:27:32 +08:00
parent b1f14bd525
commit bf67626830
3 changed files with 77 additions and 0 deletions
+43
View File
@@ -87,6 +87,49 @@ func TestAnalyticsMetricFiltersPreserveGlobalDedupAndEffectiveCount(t *testing.T
}
}
func TestAnalyticsNegativeFiltersIncludeInactiveAuthorizedChannels(t *testing.T) {
db, repo, scope, filter := prepareAnalyticsData(t)
for _, sql := range []string{
"INSERT INTO tab_promote(id,source_db,account,promote_level,parent_id,top_promote_id,busier_id) VALUES(200,'lx','inactive',1,0,0,14),(201,'lx','invisible',1,0,0,999),(202,'lx','inactive-child',2,200,200,14)",
"INSERT INTO tab_promote_apply(source_db,promote_id,game_id,status) VALUES('lx',202,1,1)",
} {
if err := db.Exec(sql).Error; err != nil {
t.Fatal(err)
}
}
no := false
filter.HasRegister, filter.HasPay = &no, &no
filter.Sources = []string{"lx"}
for _, games := range [][]string{nil, {"当前游戏甲"}} {
filter.GameNames = games
// Use the actual game name; the report's saved historical name can differ.
if len(games) > 0 {
if err := db.Table("tab_game").Where("source_db='lx' AND id=1").Pluck("game_name", &filter.GameNames).Error; err != nil {
t.Fatal(err)
}
}
data, err := repo.Aggregate(context.Background(), business.ChannelAnalytics, scope, filter)
if err != nil {
t.Fatal(err)
}
found := false
for _, row := range data.Rows {
if row.ID == 201 || row.ID == 202 {
t.Fatalf("permission or tree aggregation leak: %+v", row)
}
if row.ID == 200 {
found = true
if row.Counts.Register != 0 || row.Pay != "0" {
t.Fatalf("inactive metrics: %+v", row)
}
}
}
if !found {
t.Fatalf("inactive authorized channel missing with games %v", filter.GameNames)
}
}
}
func TestAnalyticsRowsOnlyComeFromSelectedPeriod(t *testing.T) {
db, repo, scope, filter := prepareAnalyticsData(t)
for _, sql := range []string{