This commit is contained in:
aozhiwei 2019-12-30 11:07:24 +08:00
parent da8bfd2092
commit 3eaf47f0d4

View File

@ -122,7 +122,7 @@ def internalDayReadMysqlData():
temp_idx = 0 temp_idx = 0
while 1: while 1:
cursor.execute('SELECT accountid, user_name, avatar_url, pass, cumul_coin, idx' cursor.execute('SELECT accountid, user_name, avatar_url, pass, cumul_coin, idx'
' FROM user WHERE idx > %s LIMIT 0, 1000' % (last_idx)) ' FROM user WHERE idx > %s LIMIT 0, 5000' % (last_idx))
has_data = False has_data = False
for row in cursor: for row in cursor:
@ -134,10 +134,9 @@ def internalDayReadMysqlData():
temp_idx = int(row[5]) temp_idx = int(row[5])
if (temp_idx > last_idx) : if (temp_idx > last_idx) :
last_idx = int(row[5]) last_idx = int(row[5])
time.sleep(0.001);
if not has_data: if not has_data:
break break
r = getRedis() r = getRedis()
updateRank(r, pass_list, coin_list) updateRank(r, pass_list, coin_list)
@ -176,37 +175,37 @@ def readMysqlData(rushtime):
last_idx = 0 last_idx = 0
temp_idx = 0 temp_idx = 0
while 1: while 1:
cursor.execute('SELECT accountid, user_name, avatar_url, pass, cumul_coin, idx FROM user ' cursor.execute('SELECT accountid, user_name, avatar_url, pass, cumul_coin, idx, modify_time FROM user '
' WHERE idx > %s LIMIT 0, 1000' % (last_idx)) ' WHERE modify_time > %s AND idx > %s LIMIT 0, 1000' % (time.time() - 300, last_idx))
has_data = False has_data = False
for row in cursor: for row in cursor:
has_data = True has_data = True
#更新击杀 #更新通关
delRepeatData(row, pass_list) delRepeatData(row, pass_list)
refreshData(row, pass_list) refreshData(row, pass_list)
temp_idx = int(row[5]) temp_idx = int(row[5])
if (temp_idx > last_idx) : if (temp_idx > last_idx) :
last_idx = int(row[5]) last_idx = int(row[5])
time.sleep(0.001);
if not has_data: if not has_data:
break break
last_idx = 0 last_idx = 0
temp_idx = 0 temp_idx = 0
while 1: while 1:
cursor.execute('SELECT accountid, user_name, avatar_url, pass, cumul_coin, idx FROM user ' cursor.execute('SELECT accountid, user_name, avatar_url, pass, cumul_coin, idx, modify_time FROM user '
' WHERE idx > %s LIMIT 0, 1000' % (last_idx)) ' WHERE modify_time > %s AND idx > %s LIMIT 0, 1000' % (time.time() - 300, last_idx))
has_data = False has_data = False
for row in cursor: for row in cursor:
has_data = True has_data = True
#更新胜场 #更新金币
delRepeatData(row, coin_list) delRepeatData(row, coin_list)
refreshCoinData(row, coin_list) refreshCoinData(row, coin_list)
temp_idx = int(row[5]) temp_idx = int(row[5])
if (temp_idx > last_idx) : if (temp_idx > last_idx) :
last_idx = int(row[5]) last_idx = int(row[5])
time.sleep(0.001);
if not has_data: if not has_data:
break break
updateRank(r, pass_list, coin_list) updateRank(r, pass_list, coin_list)
tornado.ioloop.IOLoop.current().call_later(rushtime, tornado.ioloop.IOLoop.current().call_later(rushtime,
lambda : readMysqlData(rushtime) lambda : readMysqlData(rushtime)