Commit 4befca07 authored by 张彦钊's avatar 张彦钊

change tets

parent 43ffadf4
import pymysql import pymysql
import datetime import datetime
import json
def get_esmm_users(): def get_esmm_users():
...@@ -9,15 +10,38 @@ def get_esmm_users(): ...@@ -9,15 +10,38 @@ def get_esmm_users():
stat_date = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y-%m-%d") stat_date = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y-%m-%d")
print(stat_date) print(stat_date)
sql = "select distinct device_id,city_id from data_feed_exposure_precise " \ sql = "select distinct device_id,city_id from data_feed_exposure_precise " \
"where stat_date = '{}' limit 20".format(stat_date) "where stat_date = '{}'".format(stat_date)
cursor.execute(sql) cursor.execute(sql)
result = list(cursor.fetchall()) result = list(cursor.fetchall())
print(result[:2])
return result return result
def get_user_profile(device_id): def get_user_profile():
pass r = redis.Redis(host="172.16.40.135", port=5379, password="", db=2)
cl_id = "9C5E7C73-380C-4623-8F48-A64C8034E315"
key = "user:portrait_tags:cl_id:" + str(cl_id)
tmp = json.loads(r.get(key).decode('utf-8'))
# todo 找赵晨把search word映射成tag
tags = {}
for i in tmp:
tags[i["content"]] = i["score"]
tags = sorted(tags.items(), key=lambda x: x[1], reverse=True)
tag_score = {}
if len(tmp) > 5:
for i in list(tags.keys())[:5]:
tag_score[i] = tags[i]
print(tag_score)
return tag_score
else:
print(tags)
return tags
def transform_to_tag(user_profile): def transform_to_tag(user_profile):
...@@ -55,7 +79,8 @@ if __name__ == "__main__": ...@@ -55,7 +79,8 @@ if __name__ == "__main__":
# #
# total_samples.todf # total_samples.todf
# to_data_base(df) # to_data_base(df)
get_esmm_users() get_user_profile()
......
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