Commit 9491a0b9 authored by 赵威's avatar 赵威

portrait performance

parent 5123d2da
......@@ -9,8 +9,13 @@ def get_user_portrait_tag3_redis_key(device_id):
def items_gt_score(d, limit_score=0, tags_num=5):
new_d = dict(sorted(d.items(), key=lambda x: x[1], reverse=True))
res = {tag: float(score) for tag, score in new_d.items() if float(score) >= limit_score}
return list(res.keys())[:tags_num]
res = []
count = 0
for (tag, score) in new_d.items():
if float(score) >= limit_score and count < tags_num:
res.append(tag)
count += 1
return res
def get_user_portrait_tag3_from_redis(device_id, limit_score=0, tags_num=5):
......
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