Commit 5a2626a9 authored by 张彦钊's avatar 张彦钊

change test file

parent 191cd7d2
...@@ -76,57 +76,61 @@ def get_queues(device_id,city_id): ...@@ -76,57 +76,61 @@ def get_queues(device_id,city_id):
def tag_boost(cid_str, tag_list=[15,21,22,85,86]): def tag_boost(cid_str, tag_list=[15,21,22,85,86]):
if cid_str is not None or cid_str != "": if cid_str is not None or cid_str != "":
cids = cid_str.split(",") cids = cid_str.split(",")
if len(cids) > 6 and len(tag_list) > 0: try:
db = pymysql.connect(host='172.16.40.158', port=4000, user='root', passwd='3SYz54LS9#^9sBvC', db='eagle') if len(cids) > 6 and len(tag_list) > 0:
db = pymysql.connect(host='172.16.40.158', port=4000, user='root', passwd='3SYz54LS9#^9sBvC',
sql = "select id,group_concat(diary_id) from " \ db='eagle')
"(select a.diary_id,b.id from src_mimas_prod_api_diary_tags a left join src_zhengxing_api_tag b " \
"on a.tag_id = b.id where b.tag_type < '4' and a.diary_id in {}) tmp " \ sql = "select id,group_concat(diary_id) from " \
"where id in {} group by id".format(tuple(cids), tuple(tag_list)) "(select a.diary_id,b.id from src_mimas_prod_api_diary_tags a left join src_zhengxing_api_tag b " \
cursor = db.cursor() "on a.tag_id = b.id where b.tag_type < '4' and a.diary_id in {}) tmp " \
cursor.execute(sql) "where id in {} group by id".format(tuple(cids), tuple(tag_list))
result = cursor.fetchall() cursor = db.cursor()
if len(result) > 0: cursor.execute(sql)
tag_cids = {} result = cursor.fetchall()
left_cids = [] if len(result) > 0:
for i in result: tag_cids = {}
tmp = i[1].split(",") left_cids = []
tag_cids[i[0]] = tmp for i in result:
left_cids.extend(tmp) tmp = i[1].split(",")
tag_cids[i[0]] = tmp
left_cids = list(set(left_cids)) left_cids.extend(tmp)
right_cids = [i for i in cids if i not in left_cids]
tag_cids["right"] = right_cids left_cids = list(set(left_cids))
tag_list.append("right") right_cids = [i for i in cids if i not in left_cids]
sort_cids = [] tag_cids["right"] = right_cids
n = 0 tag_list.append("right")
while n != len(tag_cids)-1: sort_cids = []
for i in tag_list: n = 0
if i in tag_cids.keys(): while n != len(tag_cids) - 1:
if len(tag_cids[i]) > 0: for i in tag_list:
sort_cids.append(tag_cids[i][0]) if i in tag_cids.keys():
value = tag_cids[i] if len(tag_cids[i]) > 0:
value.pop(0) sort_cids.append(tag_cids[i][0])
tag_cids[i] = value value = tag_cids[i]
if len(value) == 0 and i != "right": value.pop(0)
n = n + 1 tag_cids[i] = value
if len(value) == 0 and i != "right":
if len(tag_cids["right"]) > 0: n = n + 1
sort_cids.extend(tag_cids["right"])
if len(tag_cids["right"]) > 0:
news_ids = [] sort_cids.extend(tag_cids["right"])
for id in sort_cids:
if id not in news_ids: news_ids = []
news_ids.append(id) for id in sort_cids:
if id not in news_ids:
new_str = ",".join([str(i) for i in news_ids]) news_ids.append(id)
return new_str
new_str = ",".join([str(i) for i in news_ids])
return new_str
else:
return cid_str
else: else:
return cid_str return cid_str
else: except:
return cid_str return cid_str
else: else:
return cid_str return cid_str
......
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