fix: 修复排行榜未能正确加载的问题。

main
NorthLan 3 years ago
parent 66ee7ea63a
commit 9f4cc52b62

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

@ -25,8 +25,8 @@ func NewServiceContext(c config.Config) *ServiceContext {
Logger: logger.New(
log.New(os.Stdout, "\r\n", log.LstdFlags),
logger.Config{
SlowThreshold: 1 * time.Second,
LogLevel: logger.Info,
SlowThreshold: 2 * time.Second,
LogLevel: logger.Warn,
IgnoreRecordNotFoundError: true,
Colorful: true,
},

Loading…
Cancel
Save