fix: 统一商务表格展示并修正筛选和全量排序
This commit is contained in:
@@ -254,6 +254,7 @@ func sortAnalytics(rows []*AnalyticsRow, kind AnalyticsKind, field string, ascen
|
||||
}
|
||||
allowed := map[string]bool{"newRegisterCount": true, "activeCount": true, "payUserCount": true, "newPayUserCount": true, "totalPay": true, "payRate": true}
|
||||
if kind == GameAnalytics {
|
||||
allowed["gameId"] = true
|
||||
allowed["arpu"] = true
|
||||
allowed["arppu"] = true
|
||||
} else {
|
||||
@@ -277,7 +278,7 @@ func sortAnalytics(rows []*AnalyticsRow, kind AnalyticsKind, field string, ascen
|
||||
n = big.NewRat(row.Counts.Pay, 1)
|
||||
case "newPayUserCount":
|
||||
n = big.NewRat(row.Counts.NewPay, 1)
|
||||
case "promoteId":
|
||||
case "promoteId", "gameId":
|
||||
n = big.NewRat(row.ID, 1)
|
||||
case "promoteType":
|
||||
value := int64(0)
|
||||
|
||||
@@ -6,6 +6,16 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestGameIDSortDoesNotFallBackToRechargeAmount(t *testing.T) {
|
||||
rows := []*AnalyticsRow{{AnalyticsKey: AnalyticsKey{ID: 20, SourceDB: "lx"}, Pay: "1.00"}, {AnalyticsKey: AnalyticsKey{ID: 3, SourceDB: "lx"}, Pay: "900.00"}}
|
||||
if err := sortAnalytics(rows, GameAnalytics, "gameId", true); err != nil || rows[0].ID != 3 {
|
||||
t.Fatal("game ID ascending sort failed")
|
||||
}
|
||||
if err := sortAnalytics(rows, GameAnalytics, "gameId", false); err != nil || rows[0].ID != 20 {
|
||||
t.Fatal("game ID descending sort fell back to recharge amount")
|
||||
}
|
||||
}
|
||||
|
||||
type analyticsRepoFake struct {
|
||||
data *AnalyticsData
|
||||
scope AnalyticsScope
|
||||
|
||||
@@ -142,6 +142,8 @@ func registrationSort(field string) string {
|
||||
}
|
||||
func spendSort(field string) string {
|
||||
switch field {
|
||||
case "id":
|
||||
return "id"
|
||||
case "payAmount", "pay_amount", "amount":
|
||||
return "payAmount"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user