Commit 18fd035c authored by 张彦钊's avatar 张彦钊

change test file

parent 881c37b1
This diff is collapsed.
......@@ -23,7 +23,7 @@ def filter_history(device_id,cid_list):
r.sadd(all_key, *r.smembers(today_key))
def get_data():
def get_dairy():
device_id = "868080041007173"
r = redis.StrictRedis.from_url("redis://redis.paas-test.env:6379/0")
......@@ -35,7 +35,7 @@ def get_data():
user_portrait_diary_key = 'user_portrait_recommend_diary_queue:device_id:%s:%s' % \
(device_id, datetime.datetime.now().strftime('%Y-%m-%d'))
user_cids = list(range(2,20))
user_cids = list(range(2,6))
user_cids = [str(i) for i in user_cids]
r.hset(user_portrait_diary_key,'diary_queue',json.dumps(user_cids))
r.hset(user_portrait_diary_key, 'cursor', "0")
......@@ -44,7 +44,7 @@ def get_data():
print(r.hgetall(user_portrait_diary_key))
search_diary_recommend_key = "TS:search_recommend_diary_queue:device_id:" + str(device_id)
serach_cids = list(range(20,39))
serach_cids = list(range(20,26))
serach_cids = [str(i) for i in serach_cids]
r.hset(search_diary_recommend_key, 'diary_queue', json.dumps(serach_cids))
print("search")
......@@ -52,7 +52,7 @@ def get_data():
diary_recommend_key = "TS:recommend_diary_queue:device_id:" + str(device_id)
ts_cids = list(range(40,60))
ts_cids = list(range(40,46))
ts_cids = [str(i) for i in ts_cids]
r.hset(diary_recommend_key, 'diary_queue', json.dumps(ts_cids))
print("ts")
......@@ -72,6 +72,42 @@ def get_data():
print(r.hgetall(personal_key))
def get_qa():
device_id = "868080041007173"
r = redis.StrictRedis.from_url("redis://redis.paas-test.env:6379/0")
dislike_key = str(device_id) + "_dislike_qa"
dislike_cids = [529401,529412,529403]
r.sadd(dislike_key, *dislike_cids)
print("不喜欢")
print(r.smembers(dislike_key))
search_qa_recommend_key = "TS:search_recommend_answer_queue:device_id:" + str(device_id)
r.hset(search_qa_recommend_key,'answer_queue',json.dumps(list(range(529401,529408))))
print(r.hgetall(search_qa_recommend_key))
def get_topic():
device_id = "868080041007173"
r = redis.StrictRedis.from_url("redis://redis.paas-test.env:6379/0")
dislike_key = str(device_id) + "_dislike_tractate"
dislike_cids = [2,37]
r.sadd(dislike_key, *dislike_cids)
print("不喜欢")
print(r.smembers(dislike_key))
search_topic_recommend_key = "TS:search_recommend_tractate_queue:device_id:" + str(device_id)
r.hset(search_topic_recommend_key,'tractate_queue',json.dumps(list(range(1,4))))
print(r.hgetall(search_topic_recommend_key))
def yanzheng():
device_id = "E417C286-40A4-42F6-BDA9-AEEBD8FEC3B6"
r = redis.Redis(host="172.16.40.135", port=5379, db=2, socket_timeout=2000)
......@@ -84,7 +120,9 @@ def get_data():
if __name__ == "__main__":
# cid = [16,18,20]
# filter_history("hello",cid)
get_data()
get_topic()
......
......@@ -14,6 +14,7 @@ def get_esmm_users():
"where stat_date = '{}'".format(stat_date)
cursor.execute(sql)
result = list(cursor.fetchall())
db.close()
return result
......@@ -37,7 +38,23 @@ def get_user_profile():
return tags
def get_searchworlds_to_tagid():
try:
sql = 'select id, name from api_tag where is_online = 1 and tag_type < 4'
db = pymysql.connect(host='172.16.30.141', port=3306, user='work',
passwd='BJQaT9VzDcuPBqkd', db='zhengxing')
cursor = db.cursor()
cursor.execute(sql)
tag_id = cursor.fetchall()
db.close()
searchworlds_to_tagid = {}
for i in tag_id:
searchworlds_to_tagid[i[1]] = i[0]
print(searchworlds_to_tagid)
return searchworlds_to_tagid
except Exception as e:
print(e)
......@@ -80,7 +97,7 @@ if __name__ == "__main__":
#
# total_samples.todf
# to_data_base(df)
get_user_profile()
get_searchworlds_to_tagid()
......
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