Commit 85ae354e authored by 张彦钊's avatar 张彦钊

update dairyQueueUpdate file

parent 519e6419
......@@ -170,21 +170,21 @@ def update_sql_dairy_queue(queue_name, diary_id,device_id, city_id):
# 更新前获取最新的native_queue
def get_native_queue(device_id,city_id):
def get_megacity_queue(device_id, city_id):
db = pymysql.connect(host='rm-m5e842126ng59jrv6.mysql.rds.aliyuncs.com', port=3306, user='doris',
passwd='o5gbA27hXHHm', db='doris_prod')
cursor = db.cursor()
sql = "select native_queue from device_diary_queue " \
sql = "select megacity_queue from device_diary_queue " \
"where device_id = '{}' and city_id = '{}';".format(device_id,city_id)
cursor.execute(sql)
result = cursor.fetchall()
df = pd.DataFrame(list(result))
if not df.empty:
native_queue = df.loc[0,0].split(",")
native_queue = list(map(lambda x:"diary|"+str(x),native_queue))
megacity_queue = df.loc[0, 0].split(",")
megacity_queue = list(map(lambda x: "diary|" + str(x), megacity_queue))
db.close()
print("成功获取native_queue")
return native_queue
print("成功获取megacity_queue")
return megacity_queue
else:
return False
......@@ -226,27 +226,21 @@ def pipe_line(queue_name, queue_arg, device_id):
def user_update(device_id,city_id,data_set_cid):
global native_queue_list
global megacity_queue_list
#TODO 测试成功后把下面的list还原
queue_name_list = ["native_queue","nearby_queue","nation_queue","megacity_queue"]
for queue_name in queue_name_list:
queue_list = get_queue(device_id, city_id,queue_name)
if queue_name == "native_queue":
native_queue_list = queue_list
if queue_name == "megacity_queue":
megacity_queue_list = queue_list
if queue_list:
queue_predict = list(set(queue_list) & set(data_set_cid))
queue_not_predict = list(set(queue_list) - set(data_set_cid))
queue_arg = [queue_predict,queue_not_predict,queue_list]
if queue_predict != []:
diary_queue = pipe_line(queue_name, queue_arg, device_id)
print("diaryqu")
print(diary_queue[:30])
print("native_queue_list")
print(native_queue_list[:30])
print("get_native_queue")
print(get_native_queue(device_id, city_id)[:30])
if diary_queue and (native_queue_list == get_native_queue(device_id, city_id)):
if diary_queue and (megacity_queue_list == get_megacity_queue(device_id, city_id)):
update_sql_dairy_queue(queue_name, diary_queue, device_id, city_id)
print("更新结束")
else:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment