test_game_banner.go 928 Bytes
Newer Older
hujiebin's avatar
hujiebin committed
1 2 3 4 5 6 7
package main

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

hujiebin's avatar
hujiebin committed
8 9
// cat 146.json  | grep 'gameId\\"\:17' | wc -l
// 如果mysql navicate中导出json,可以用上面的命令,是准确的。
hujiebin's avatar
hujiebin committed
10 11 12 13 14 15 16
type RpcLog struct {
	Type int
	Msg  string
}

type Msg struct {
	GameType int `json:"gameType"`
hujiebin's avatar
hujiebin committed
17
	GameId   int `json:"gameId"`
hujiebin's avatar
hujiebin committed
18 19
}

hujiebin's avatar
1  
hujiebin committed
20
var GameTypeMap = map[int]string{
hujiebin's avatar
hujiebin committed
21 22 23 24
	//0: "slot",
	//5: "幸运盒子",
	//6: "水果机",
	17: "赛车",
hujiebin's avatar
1  
hujiebin committed
25 26
}

hujiebin's avatar
hujiebin committed
27 28
func main() {
	var rpcLogs []RpcLog
hujiebin's avatar
hujiebin committed
29 30
	if err := mysql.ProdReadOnlyDB.Table("rpc_log_202308").Where("`type` = 146").
		Where("created_time >= ?", "2023-08-22 15:57:49").Find(&rpcLogs).Error; err != nil {
hujiebin's avatar
hujiebin committed
31 32 33 34 35 36 37 38
		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)
		}
hujiebin's avatar
hujiebin committed
39
		data[msg.GameId]++
hujiebin's avatar
hujiebin committed
40
	}
hujiebin's avatar
hujiebin committed
41 42
	for gameId, count := range data {
		println(GameTypeMap[gameId], count)
hujiebin's avatar
hujiebin committed
43 44
	}
}