diff --git a/app/user_center/rpc/internal/logic/rank/rank_job.go b/app/user_center/rpc/internal/logic/rank/rank_job.go index dce8ec7..aaf65a1 100644 --- a/app/user_center/rpc/internal/logic/rank/rank_job.go +++ b/app/user_center/rpc/internal/logic/rank/rank_job.go @@ -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)) } } diff --git a/app/user_center/rpc/internal/svc/service_context.go b/app/user_center/rpc/internal/svc/service_context.go index 13bc300..22783ec 100644 --- a/app/user_center/rpc/internal/svc/service_context.go +++ b/app/user_center/rpc/internal/svc/service_context.go @@ -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, },