diff --git a/tools/rankserver/app.py b/tools/rankserver/app.py index dc4b138..637bf47 100644 --- a/tools/rankserver/app.py +++ b/tools/rankserver/app.py @@ -91,21 +91,6 @@ def _refreshData(row, data_list, data_info): if (len(data_list) > 50): del data_list[50:] -#更新排行榜 -def _updateKillRank(r, channel, kill_list): - kill_list.sort(key=take_kills, reverse=True) - kill_rank = [] - for kill_index in range(min(50, len(kill_list))): - kill_rank.append(kill_list[kill_index]) - r.set("game2005api:kill_rank_" + channel, json.dumps(kill_rank)) - -def _updateWinRank(r, channel, win_list): - win_list.sort(key=take_game_times, reverse=True) - win_rank = [] - for win_index in range(min(50, len(win_list))): - win_rank.append(win_list[win_index]) - r.set("game2005api:win_rank_" + channel, json.dumps(win_rank)) - def _updateScoreRank(r, channel, integral_list): integral_list.sort(key=take_integral_times, reverse=True) integral_rank = [] @@ -116,8 +101,6 @@ def _updateScoreRank(r, channel, integral_list): def fullUpdateRank(): f7.udplog.info('fullUpdateRank begin') mysql_conf = json.loads(open(CONFIG_DIR + '/rankserver.mysql.cluster.json', 'r').read()) - kill_hash = {} - win_hash = {} integral_hash = {} for conf in mysql_conf: conn = pymysql.connect(host = conf['host'], @@ -132,22 +115,11 @@ def fullUpdateRank(): temp_idx = 0 while 1: cursor.execute('SELECT accountid, user_name, avatar_url, kills, alive_time,' - ' harm, win_times, game_times, idx, integral, season_time FROM user WHERE idx > %s LIMIT 0, 1000' % (last_idx)) + ' harm, win_times, game_times, idx, integral, season_time ' + 'FROM user WHERE idx > %s LIMIT 0, 1000' % (last_idx)) has_data = False for row in cursor: has_data = True - #更新击杀榜 - channel = f7.getChannelByAccountId(row[0]) - if checkchannel(channel): - if channel not in kill_hash: - kill_hash[channel] = [] - _refreshData(row, kill_hash[channel], take_kills) - #更新胜场榜 - channel = f7.getChannelByAccountId(row[0]) - if checkchannel(channel): - if channel not in win_hash: - win_hash[channel] = [] - _refreshData(row, win_hash[channel], take_game_times) #更新积分榜 channel = f7.getChannelByAccountId(row[0]) if checkchannel(channel): @@ -163,10 +135,6 @@ def fullUpdateRank(): conn.close() r = _getRedis() - for channel in kill_hash: - _updateKillRank(r, channel, kill_hash[channel]) - for channel in win_hash: - _updateWinRank(r, channel, win_hash[channel]) for channel in integral_hash: _updateScoreRank(r, channel, integral_hash[channel]) f7.udplog.info('fullUpdateRank end') @@ -182,8 +150,6 @@ def _fullUpdateRank(rushtime): def incrementUpdateRank(): mysql_conf = json.loads(open(CONFIG_DIR + '/rankserver.mysql.cluster.json', 'r').read()) r = _getRedis() - kill_hash = {} - win_hash = {} integral_hash = {} for conf in mysql_conf: conn = pymysql.connect(host = conf['host'], @@ -205,18 +171,6 @@ def incrementUpdateRank(): has_data = True channel = f7.getChannelByAccountId(row[0]) if checkchannel(channel): - #更新击杀榜 - if channel not in kill_hash: - kill_list = r.get('game2005api:kill_rank_' + channel) - kill_hash[channel] = [] if not kill_list else json.loads(kill_list) - _delRepeatData(row, kill_hash[channel]) - _refreshData(row, kill_hash[channel], take_kills) - #更新胜场榜 - if channel not in win_hash: - win_list = r.get('game2005api:win_rank_' + channel) - win_hash[channel] = [] if not win_list else json.loads(win_list) - _delRepeatData(row, win_hash[channel]) - _refreshData(row, win_hash[channel], take_game_times) #更新积分榜 if channel not in integral_hash: integral_list = r.get('game2005api:integral_rank_' + channel) @@ -231,15 +185,10 @@ def incrementUpdateRank(): cursor.close() conn.close() - for channel in kill_hash: - _updateKillRank(r, channel, kill_hash[channel]) - for channel in win_hash: - _updateWinRank(r, channel, win_hash[channel]) for channel in integral_hash: _updateScoreRank(r, channel, integral_hash[channel]) f7.udplog.info('incrementUpdateRank end') -#每5分钟读取mysql里发生改变过的数据更新排行榜 def _incrementUpdateRank(rushtime): def done_callback(): f7.timer.callLater(rushtime, diff --git a/webapp/controller/UserController.class.php b/webapp/controller/UserController.class.php index 78fda8f..ea1b7bb 100644 --- a/webapp/controller/UserController.class.php +++ b/webapp/controller/UserController.class.php @@ -149,8 +149,8 @@ class UserController extends BaseAuthedController { 'last_season_id' => $currSeasonMeta ? $currSeasonMeta['id'] : 0, 'head_list' => json_encode($headList), 'head_frame_list' => json_encode($headFrameList), - 'score_createtime' => $this->_getNowTime(), - 'best_rank_createtime' => $this->_getNowTime(), + 'score_modifytime' => $this->_getNowTime(), + 'best_rank_modifytime' => $this->_getNowTime(), 'createtime' => $this->_getNowTime(), 'modifytime' => $this->_getNowTime(), )