test_game_banner.go 782 Bytes
Newer Older
hujiebin's avatar
hujiebin committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
package main

import (
	"encoding/json"
	"git.hilo.cn/hilo-common/script/mysql"
)

type RpcLog struct {
	Type int
	Msg  string
}

type Msg struct {
	GameType int `json:"gameType"`
}

hujiebin's avatar
1  
hujiebin committed
17 18 19 20 21 22
var GameTypeMap = map[int]string{
	0: "slot",
	5: "幸运盒子",
	6: "水果机",
}

hujiebin's avatar
hujiebin committed
23 24 25
func main() {
	var rpcLogs []RpcLog
	if err := mysql.ProdReadOnlyDB.Table("rpc_log_202303 ").Where("`type` = 146").
hujiebin's avatar
1  
hujiebin committed
26
		Where("created_time >= ? and created_time < ?", "2023-03-09", "2023-03-13").Find(&rpcLogs).Error; err != nil {
hujiebin's avatar
hujiebin committed
27 28 29 30 31 32 33 34 35 36 37
		panic(err)
	}
	var data = make(map[int]int)
	for _, log := range rpcLogs {
		msg := new(Msg)
		if err := json.Unmarshal([]byte(log.Msg), msg); err != nil {
			panic(err)
		}
		data[msg.GameType]++
	}
	for gameType, count := range data {
hujiebin's avatar
1  
hujiebin committed
38
		println(GameTypeMap[gameType], count)
hujiebin's avatar
hujiebin committed
39 40
	}
}