fix: align business reports and record task migration progress
This commit is contained in:
@@ -61,6 +61,32 @@ func TestAnalyticsChannelTreeAndAdminOfficialRows(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAnalyticsMetricFiltersPreserveGlobalDedupAndEffectiveCount(t *testing.T) {
|
||||
db, repo, scope, filter := prepareAnalyticsData(t)
|
||||
scope.Viewer = business.UserScope{All: true}
|
||||
yes, no := true, false
|
||||
filter.HasRegister, filter.HasPay = &yes, &yes
|
||||
// The same real identity occurs under different root channels/platforms.
|
||||
// All rows match, so the filtered total must keep the original global count.
|
||||
data, err := repo.Aggregate(context.Background(), business.ChannelAnalytics, scope, filter)
|
||||
if err != nil || len(data.Rows) != 5 || data.GlobalCounts.Register != 4 || portraitTestMoney(data.GlobalPay) != "2070.60" {
|
||||
t.Fatalf("filtered summary lost global deduplication: %+v %v", data, err)
|
||||
}
|
||||
if err := db.Exec("UPDATE tab_sw_report_day SET total_pay=0 WHERE source_db='lx' AND promote_id IN (100,101,102)").Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
filter.HasPay = &no
|
||||
data, err = repo.Aggregate(context.Background(), business.ChannelAnalytics, scope, filter)
|
||||
if err != nil || len(data.Rows) != 1 || data.Rows[0].ID != 100 || portraitTestMoney(data.GlobalPay) != "0.00" || data.GlobalCounts.Register != 2 {
|
||||
t.Fatalf("no-payment filter must keep the whole root scope and matching totals: %+v %v", data, err)
|
||||
}
|
||||
filter.HasRegister = &no
|
||||
data, err = repo.Aggregate(context.Background(), business.ChannelAnalytics, scope, filter)
|
||||
if err != nil || len(data.Rows) != 0 || data.GlobalCounts.Register != 0 || data.EffectiveCount != 0 {
|
||||
t.Fatalf("combined filters must use AND and return empty totals: %+v %v", data, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAnalyticsRowsOnlyComeFromSelectedPeriod(t *testing.T) {
|
||||
db, repo, scope, filter := prepareAnalyticsData(t)
|
||||
for _, sql := range []string{
|
||||
|
||||
Reference in New Issue
Block a user