|
|
@ -76,9 +76,17 @@ func InitRankJob(svcCtx *svc.ServiceContext) {
|
|
|
|
func (j *Job) initJob() {
|
|
|
|
func (j *Job) initJob() {
|
|
|
|
logx.Info("开启排行榜服务...")
|
|
|
|
logx.Info("开启排行榜服务...")
|
|
|
|
j.initByType(model.RankTypeDamage)
|
|
|
|
j.initByType(model.RankTypeDamage)
|
|
|
|
|
|
|
|
j.initByType(model.RankTypeDeDamage)
|
|
|
|
j.initByType(model.RankTypeGeneral)
|
|
|
|
j.initByType(model.RankTypeGeneral)
|
|
|
|
|
|
|
|
j.initByType(model.RankTypeDeGeneral)
|
|
|
|
j.initByType(model.RankTypeKillUnit)
|
|
|
|
j.initByType(model.RankTypeKillUnit)
|
|
|
|
|
|
|
|
j.initByType(model.RankTypeDeKillUnit)
|
|
|
|
j.initByType(model.RankTypeKillPlayer)
|
|
|
|
j.initByType(model.RankTypeKillPlayer)
|
|
|
|
|
|
|
|
j.initByType(model.RankTypeDeKillPlayer)
|
|
|
|
|
|
|
|
j.initByType(model.RankTypeWin)
|
|
|
|
|
|
|
|
j.initByType(model.RankTypeLost)
|
|
|
|
|
|
|
|
j.initByType(model.RankTypeFirstBlood)
|
|
|
|
|
|
|
|
j.initByType(model.RankTypeDeFirstBlood)
|
|
|
|
|
|
|
|
|
|
|
|
// job read and update
|
|
|
|
// job read and update
|
|
|
|
c := cron.New()
|
|
|
|
c := cron.New()
|
|
|
@ -213,6 +221,10 @@ func (j *Job) initByType(rankType int32) {
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rankZSet, _, err := j.getRankInstanceAndScoreType(rankType)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
for _, user := range list {
|
|
|
|
for _, user := range list {
|
|
|
|
// 缓存用户信息
|
|
|
|
// 缓存用户信息
|
|
|
|
j.userCache.Add(user.UserId, CachedUserInfo{
|
|
|
|
j.userCache.Add(user.UserId, CachedUserInfo{
|
|
|
@ -220,16 +232,7 @@ func (j *Job) initByType(rankType int32) {
|
|
|
|
Username: user.PUname,
|
|
|
|
Username: user.PUname,
|
|
|
|
Avatar: user.PAvatar,
|
|
|
|
Avatar: user.PAvatar,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
switch rankType {
|
|
|
|
rankZSet.Add(user.UserId, int32(user.Score))
|
|
|
|
case model.RankTypeDamage:
|
|
|
|
|
|
|
|
j.damageRank.Add(user.UserId, int32(user.Score))
|
|
|
|
|
|
|
|
case model.RankTypeGeneral:
|
|
|
|
|
|
|
|
j.generalRank.Add(user.UserId, int32(user.Score))
|
|
|
|
|
|
|
|
case model.RankTypeKillUnit:
|
|
|
|
|
|
|
|
j.killUnitRank.Add(user.UserId, int32(user.Score))
|
|
|
|
|
|
|
|
case model.RankTypeKillPlayer:
|
|
|
|
|
|
|
|
j.killPlayerRank.Add(user.UserId, int32(user.Score))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|