Ignore wallet gift events in dashboard metrics

This commit is contained in:
zhx 2026-05-27 14:42:09 +08:00
parent c02d057c80
commit 071daba7a5
2 changed files with 4 additions and 7 deletions

View File

@ -19,7 +19,7 @@ var walletGameEvents = map[string]struct{}{
func (m *Mapper) mapWalletGame(ctx context.Context, schema string, table string, action string, row Row) ([]Contribution, error) { func (m *Mapper) mapWalletGame(ctx context.Context, schema string, table string, action string, row Row) ([]Contribution, error) {
eventType := row.String("event_type") eventType := row.String("event_type")
if isWalletGiftConsumeEvent(eventType) { if isWalletGiftConsumeEvent(eventType) {
return m.mapWalletGift(ctx, schema, table, action, row) return nil, nil
} }
if !isWalletGameEvent(eventType) { if !isWalletGameEvent(eventType) {
return nil, nil return nil, nil

View File

@ -73,7 +73,7 @@ func TestWalletLuckyGiftIsNotMappedAsGiftConsume(t *testing.T) {
} }
} }
func TestWalletGiveGiftIsMappedAsGiftConsume(t *testing.T) { func TestWalletGiveGiftIsNotMappedAsGiftConsume(t *testing.T) {
mapper := NewMapper(walletMapperTestStore{users: map[int64]UserCountry{ mapper := NewMapper(walletMapperTestStore{users: map[int64]UserCountry{
1001: {UserID: 1001, SysOrigin: "LIKEI", Country: Country{Code: "BD", Name: "Bangladesh"}}, 1001: {UserID: 1001, SysOrigin: "LIKEI", Country: Country{Code: "BD", Name: "Bangladesh"}},
}}, []string{"LIKEI"}, "UNKNOWN", 0) }}, []string{"LIKEI"}, "UNKNOWN", 0)
@ -92,11 +92,8 @@ func TestWalletGiveGiftIsMappedAsGiftConsume(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
if len(contributions) != 1 { if len(contributions) != 0 {
t.Fatalf("expected one gift contribution, got %d", len(contributions)) t.Fatalf("expected wallet GIVE_GIFT to be ignored, got %#v", contributions)
}
if !contributions[0].GiftConsume.Equal(decimal.NewFromInt(100)) {
t.Fatalf("expected gift consume 100, got %s", contributions[0].GiftConsume.String())
} }
} }