1
This commit is contained in:
parent
e39a25d864
commit
c4977b93a2
@ -4,5 +4,6 @@
|
|||||||
"immutable_base_url": "https://api.sandbox.immutable.com",
|
"immutable_base_url": "https://api.sandbox.immutable.com",
|
||||||
"hero_contract_address": "0x65570A86E5aA2B14325f8a13C70b74f7d1E2f5c9",
|
"hero_contract_address": "0x65570A86E5aA2B14325f8a13C70b74f7d1E2f5c9",
|
||||||
"immutable_api_key": "sk_imapik-test-kbe8ZWVEzySQPmdiOd8H_ac92cd",
|
"immutable_api_key": "sk_imapik-test-kbe8ZWVEzySQPmdiOd8H_ac92cd",
|
||||||
"chain_name": "imtbl-zkevm-testnet"
|
"chain_name": "imtbl-zkevm-testnet",
|
||||||
|
"scoreboard_height": 100
|
||||||
}
|
}
|
||||||
|
@ -84,6 +84,7 @@ type Config struct {
|
|||||||
immutable_base_url string
|
immutable_base_url string
|
||||||
chain_name string
|
chain_name string
|
||||||
immutable_api_key string
|
immutable_api_key string
|
||||||
|
scoreboard_height int32
|
||||||
|
|
||||||
_flags1_ uint64
|
_flags1_ uint64
|
||||||
_flags2_ uint64
|
_flags2_ uint64
|
||||||
@ -481,6 +482,14 @@ func (this *Config) HasImmutableApiKey() bool {
|
|||||||
return (this._flags1_ & (uint64(1) << 6)) > 0
|
return (this._flags1_ & (uint64(1) << 6)) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *Config) GetScoreboardHeight() int32 {
|
||||||
|
return this.scoreboard_height
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *Config) HasScoreboardHeight() bool {
|
||||||
|
return (this._flags1_ & (uint64(1) << 7)) > 0
|
||||||
|
}
|
||||||
|
|
||||||
func (this *Item) GetName() string {
|
func (this *Item) GetName() string {
|
||||||
return this.name
|
return this.name
|
||||||
}
|
}
|
||||||
@ -688,6 +697,7 @@ func (this *Config) LoadFromKv(kv map[string]interface{}) {
|
|||||||
f5.ReadMetaTableField(&this.immutable_base_url, "immutable_base_url", &this._flags1_, 3, kv)
|
f5.ReadMetaTableField(&this.immutable_base_url, "immutable_base_url", &this._flags1_, 3, kv)
|
||||||
f5.ReadMetaTableField(&this.chain_name, "chain_name", &this._flags1_, 4, kv)
|
f5.ReadMetaTableField(&this.chain_name, "chain_name", &this._flags1_, 4, kv)
|
||||||
f5.ReadMetaTableField(&this.immutable_api_key, "immutable_api_key", &this._flags1_, 6, kv)
|
f5.ReadMetaTableField(&this.immutable_api_key, "immutable_api_key", &this._flags1_, 6, kv)
|
||||||
|
f5.ReadMetaTableField(&this.scoreboard_height, "scoreboard_height", &this._flags1_, 7, kv)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Item) LoadFromKv(kv map[string]interface{}) {
|
func (this *Item) LoadFromKv(kv map[string]interface{}) {
|
||||||
|
@ -71,6 +71,7 @@ message Config
|
|||||||
optional string immutable_base_url = 3;
|
optional string immutable_base_url = 3;
|
||||||
optional string chain_name = 4;
|
optional string chain_name = 4;
|
||||||
optional string immutable_api_key = 6;
|
optional string immutable_api_key = 6;
|
||||||
|
optional int32 scoreboard_height = 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
message Item
|
message Item
|
||||||
|
99
server/light_backtask/task/rankchart.go
Normal file
99
server/light_backtask/task/rankchart.go
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
package task
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"f5"
|
||||||
|
"main/constant"
|
||||||
|
"main/mt"
|
||||||
|
"q5"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type rankchart struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
type rankitem struct {
|
||||||
|
Idx int64 `json:"idx"`
|
||||||
|
Account string `json:"account_id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Head int32 `json:"head_id"`
|
||||||
|
HeadFrame int32 `json:"head_frame"`
|
||||||
|
Score int32 `json:"score"`
|
||||||
|
Rank int32 `json:"rank"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *rankchart) init() {
|
||||||
|
// go r.processLoop()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *rankchart) unInit() {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *rankchart) processLoop() {
|
||||||
|
for {
|
||||||
|
height := mt.Table.Config.GetById(0).GetScoreboardHeight()
|
||||||
|
r.processScoreRank(height)
|
||||||
|
time.Sleep(time.Minute)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *rankchart) processScoreRank(height int32) {
|
||||||
|
sql := `SELECT idx, account_id, name, head_id, head_frame, score, score_modifytime FROM t_user WHERE idx > 0`
|
||||||
|
order := " ORDER BY score DESC, score_modifytime ASC, idx ASC "
|
||||||
|
const perpage = int32(512)
|
||||||
|
pageno := int32(1)
|
||||||
|
item := new(rankitem)
|
||||||
|
|
||||||
|
for {
|
||||||
|
datalist := []string{}
|
||||||
|
var queryerr error
|
||||||
|
lastpage := false
|
||||||
|
f5.GetGoStyleDb().PageQuery(
|
||||||
|
constant.GAME_DB,
|
||||||
|
perpage,
|
||||||
|
pageno,
|
||||||
|
sql,
|
||||||
|
[]string{},
|
||||||
|
f5.GetDbFilter().Comp([]f5.DbQueryFilter{}...),
|
||||||
|
order,
|
||||||
|
func(err error, p *f5.Pagination) {
|
||||||
|
if err != nil {
|
||||||
|
queryerr = err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.CurrentPage == p.TotalPages {
|
||||||
|
lastpage = true
|
||||||
|
}
|
||||||
|
|
||||||
|
for p.Rows.Next() {
|
||||||
|
item.Rank = int32(p.Rows.NumOfReaded()) + (pageno-1)*(perpage)
|
||||||
|
if height > 0 && item.Rank > height {
|
||||||
|
lastpage = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
item.Idx = q5.SafeToInt64(p.Rows.GetByName("idx"))
|
||||||
|
item.Account = p.Rows.GetByName("account_id")
|
||||||
|
item.Name = p.Rows.GetByName("name")
|
||||||
|
item.Head = q5.SafeToInt32(p.Rows.GetByName("head_id"))
|
||||||
|
item.HeadFrame = q5.SafeToInt32(p.Rows.GetByName("head_frame"))
|
||||||
|
item.Score = q5.SafeToInt32(p.Rows.GetByName("score"))
|
||||||
|
rankdata, _ := json.Marshal(item)
|
||||||
|
datalist = append(datalist, string(rankdata))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if len(datalist) > 0 {
|
||||||
|
// push to redis
|
||||||
|
// fmt.Println(datalist)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if queryerr != nil || lastpage {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
pageno++
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,5 @@
|
|||||||
package task
|
package task
|
||||||
|
|
||||||
import (
|
|
||||||
)
|
|
||||||
|
|
||||||
type taskMgr struct {
|
type taskMgr struct {
|
||||||
webHook
|
webHook
|
||||||
repairNft
|
repairNft
|
||||||
@ -16,6 +13,7 @@ type taskMgr struct {
|
|||||||
esCecTransfer
|
esCecTransfer
|
||||||
stackingCec
|
stackingCec
|
||||||
vester
|
vester
|
||||||
|
rankchart
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *taskMgr) Init() {
|
func (this *taskMgr) Init() {
|
||||||
@ -31,6 +29,7 @@ func (this *taskMgr) Init() {
|
|||||||
this.esCecTransfer.init()
|
this.esCecTransfer.init()
|
||||||
this.stackingCec.init()
|
this.stackingCec.init()
|
||||||
this.vester.init()
|
this.vester.init()
|
||||||
|
this.rankchart.init()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *taskMgr) UnInit() {
|
func (this *taskMgr) UnInit() {
|
||||||
@ -46,4 +45,5 @@ func (this *taskMgr) UnInit() {
|
|||||||
this.sysMail.unInit()
|
this.sysMail.unInit()
|
||||||
this.repairNft.unInit()
|
this.repairNft.unInit()
|
||||||
this.webHook.unInit()
|
this.webHook.unInit()
|
||||||
|
this.rankchart.unInit()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user