Commit d787c2fd authored by litaolemo's avatar litaolemo

update

parent 2caa1fe4
...@@ -183,46 +183,47 @@ WHERE spam_pv.device_id IS NULL ...@@ -183,46 +183,47 @@ WHERE spam_pv.device_id IS NULL
for count, res in enumerate(sql_res): for count, res in enumerate(sql_res):
# print(count, res) # print(count, res)
portratit_res = get_user_portrait_tag3_from_redis(res) portratit_res = get_user_portrait_tag3_from_redis(res)
print(count, res , portratit_res) if portratit_res:
print(count, res, portratit_res)
res_dict = {}
# res_dict = {}
#
print("-------------------------------") print("-------------------------------")
for count, res in enumerate(sql_res): # for count, res in enumerate(sql_res):
# print(count, res) # # print(count, res)
track = res.track # track = res.track
if not track: # if not track:
continue # continue
track_list = track.split(",") # track_list = track.split(",")
for one_key_word in track_list: # for one_key_word in track_list:
if one_key_word in res_dict: # if one_key_word in res_dict:
res_dict[one_key_word] += 1 # res_dict[one_key_word] += 1
else: # else:
res_dict[one_key_word] = 1 # res_dict[one_key_word] = 1
print(res_dict) # print(res_dict)
#
exception_list = ("report_status","is_open_push") # exception_list = ("report_status","is_open_push")
for action in res_dict: # for action in res_dict:
partition_date = yesterday_str # partition_date = yesterday_str
pid = hashlib.md5((partition_date + action).encode("utf8")).hexdigest() # pid = hashlib.md5((partition_date + action).encode("utf8")).hexdigest()
action_count = res_dict[action] # action_count = res_dict[action]
action_ch = name_dict.get(action) # action_ch = name_dict.get(action)
if not action_ch: # if not action_ch:
action_ch = action # action_ch = action
if action_ch in exception_list: # if action_ch in exception_list:
continue # continue
instert_sql = """replace into new_user_click_count( # instert_sql = """replace into new_user_click_count(
partition_day,pid,action_count,action_ch,action) VALUES('{partition_day}','{pid}',{action_count},'{action_ch}','{action}');""".format( # partition_day,pid,action_count,action_ch,action) VALUES('{partition_day}','{pid}',{action_count},'{action_ch}','{action}');""".format(
partition_date=partition_date, partition_day=yesterday_str, pid=pid, action_count=action_count, # partition_date=partition_date, partition_day=yesterday_str, pid=pid, action_count=action_count,
action_ch=action_ch, action=action # action_ch=action_ch, action=action
) # )
print(instert_sql) # print(instert_sql)
# cursor.execute("set names 'UTF8'") # # cursor.execute("set names 'UTF8'")
db = pymysql.connect(host='172.16.40.158', port=4000, user='st_user', passwd='aqpuBLYzEV7tML5RPsN1pntUzFy', # db = pymysql.connect(host='172.16.40.158', port=4000, user='st_user', passwd='aqpuBLYzEV7tML5RPsN1pntUzFy',
db='jerry_prod') # db='jerry_prod')
cursor = db.cursor() # cursor = db.cursor()
res = cursor.execute(instert_sql) # res = cursor.execute(instert_sql)
db.commit() # db.commit()
print(res) # print(res)
# cursor.executemany() # # cursor.executemany()
db.close() # db.close()
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