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

change test file

parent 51e53cac
...@@ -87,36 +87,42 @@ def tag_boost(cid_str, tag_list=[15,21,22,85,86]): ...@@ -87,36 +87,42 @@ def tag_boost(cid_str, tag_list=[15,21,22,85,86]):
cursor.execute(sql) cursor.execute(sql)
result = cursor.fetchall() result = cursor.fetchall()
if len(result) > 0: if len(result) > 0:
tag_cids = {} tmp_dict = {}
left_cids = [] left_cids = []
for i in result: for i in result:
tmp = i[1].split(",") tmp = i[1].split(",")
tag_cids[i[0]] = tmp tmp_dict[i[0]] = tmp
left_cids.extend(tmp) left_cids.extend(tmp)
left_cids = list(set(left_cids)) tag_cids = {}
right_cids = [i for i in cids if i not in left_cids]
tag_cids["right"] = right_cids
tag_list.append("right")
sort_cids = []
while True:
for i in tag_list: for i in tag_list:
if i in tag_cids.keys(): if i in tmp_dict.keys():
n = 0 tag_cids[i] = tmp_dict[i]
if len(tag_cids[i]) > 0: print(tag_cids)
sort_cids.append(tag_cids[i][0])
value = tag_cids[i] # left_cids = list(set(left_cids))
value.pop(0) # right_cids = [i for i in cids if i not in left_cids]
tag_cids[i] = value # tag_cids["right"] = right_cids
if len(value) == 0 and i != "right": # tag_list.append("right")
n = n + 1 # sort_cids = []
else: # while True:
n = n +1 # for i in tag_list:
if n == len(tag_cids)-1: # if i in tag_cids.keys():
if len(tag_cids["right"]) > 0: # n = 0
sort_cids.extend(tag_cids["right"]) # if len(tag_cids[i]) > 0:
print(sort_cids) # sort_cids.append(tag_cids[i][0])
return sort_cids # value = tag_cids[i]
# value.pop(0)
# tag_cids[i] = value
# if len(value) == 0 and i != "right":
# n = n + 1
# else:
# n = n +1
# if n == len(tag_cids)-1:
# if len(tag_cids["right"]) > 0:
# sort_cids.extend(tag_cids["right"])
# print(sort_cids)
# return sort_cids
else: 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