上传竞技场排行榜读取问题
This commit is contained in:
parent
d80f4178fe
commit
0662974c07
@ -28,6 +28,10 @@ func (this *modelRank) Init(service core.IService, module core.IModule, comp cor
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *modelRank) rankey() string {
|
||||||
|
return fmt.Sprintf("%s-%s", this.DBModel.ServiceId, this.TableName)
|
||||||
|
}
|
||||||
|
|
||||||
// 更新排名
|
// 更新排名
|
||||||
func (this *modelRank) updateArenaRank(users ...*pb.ArenaPlayer) (err error) {
|
func (this *modelRank) updateArenaRank(users ...*pb.ArenaPlayer) (err error) {
|
||||||
var (
|
var (
|
||||||
@ -41,11 +45,11 @@ func (this *modelRank) updateArenaRank(users ...*pb.ArenaPlayer) (err error) {
|
|||||||
for i, v := range users {
|
for i, v := range users {
|
||||||
menbers[i] = &redis.Z{Score: float64(v.Integral), Member: v.Uinfo.Uid}
|
menbers[i] = &redis.Z{Score: float64(v.Integral), Member: v.Uinfo.Uid}
|
||||||
}
|
}
|
||||||
if cmd = pipe.ZAdd(this.TableName, menbers...); err != nil {
|
if cmd = pipe.ZAdd(this.rankey(), menbers...); err != nil {
|
||||||
this.module.Errorln(err)
|
this.module.Errorln(err)
|
||||||
}
|
}
|
||||||
for i, v := range users {
|
for i, v := range users {
|
||||||
menbersCmd[i] = pipe.ZRevRank(this.TableName, v.Uinfo.Uid)
|
menbersCmd[i] = pipe.ZRevRank(this.rankey(), v.Uinfo.Uid)
|
||||||
}
|
}
|
||||||
if _, err = pipe.Exec(); err != nil {
|
if _, err = pipe.Exec(); err != nil {
|
||||||
this.module.Errorln(err)
|
this.module.Errorln(err)
|
||||||
@ -67,7 +71,7 @@ func (this *modelRank) updateArenaRank(users ...*pb.ArenaPlayer) (err error) {
|
|||||||
|
|
||||||
//获取指定区间的玩家人数
|
//获取指定区间的玩家人数
|
||||||
func (this *modelRank) queryRankByScoreArea(min, max int32) (count int64, err error) {
|
func (this *modelRank) queryRankByScoreArea(min, max int32) (count int64, err error) {
|
||||||
if count, err = this.DBModel.Redis.ZCount(fmt.Sprintf("%s-%s", this.DBModel.ServiceId, this.TableName), fmt.Sprintln(min), fmt.Sprintln(max)); err != nil {
|
if count, err = this.DBModel.Redis.ZCount(this.rankey(), fmt.Sprintln(min), fmt.Sprintln(max)); err != nil {
|
||||||
this.module.Errorln(err)
|
this.module.Errorln(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -79,7 +83,7 @@ func (this *modelRank) queryRankUser() (ranks []string, err error) {
|
|||||||
var (
|
var (
|
||||||
result []string
|
result []string
|
||||||
)
|
)
|
||||||
if result, err = this.DBModel.Redis.ZRevRange(fmt.Sprintf("%s-%s", this.DBModel.ServiceId, this.TableName), 0, 50).Result(); err != nil {
|
if result, err = this.DBModel.Redis.ZRevRange(this.rankey(), 0, 50).Result(); err != nil {
|
||||||
this.module.Errorln(err)
|
this.module.Errorln(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -93,6 +97,6 @@ func (this *modelRank) queryRankUser() (ranks []string, err error) {
|
|||||||
// 比赛结算
|
// 比赛结算
|
||||||
func (this *modelRank) raceSettlement() {
|
func (this *modelRank) raceSettlement() {
|
||||||
if isopen := this.module.modelArena.isInMaintenance(); isopen {
|
if isopen := this.module.modelArena.isInMaintenance(); isopen {
|
||||||
this.DBModel.Del(fmt.Sprintf("%s-%s", this.DBModel.ServiceId, this.TableName), db.SetDBMgoLog(false))
|
this.DBModel.Del(this.rankey(), db.SetDBMgoLog(false))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user