Commit f65d4961 authored by 桂秋月's avatar 桂秋月

新增商品冷启动脚本

parent 500db13d
......@@ -21,12 +21,12 @@ REDIS_CONFIG = {
{'host': '172.16.9.89', 'port': 6371},
{'host': '172.16.9.89', 'port': 6372},
{'host': '172.16.9.89', 'port': 6373},
{'host': '172.16.9.89', 'port': 6374},
{'host': '172.16.9.89', 'port': 6375},
{'host': '172.16.9.89', 'port': 6376}
{'host': '172.16.9.90', 'port': 6374},
{'host': '172.16.9.90', 'port': 6375},
{'host': '172.16.9.90', 'port': 6376}
],
'REDIS_EXPIRE_TIME': 6000,
'REDIS_MAX_CONNECTIONS': 50,
'REDIS_MAX_CONNECTIONS': 10,
'REDIS_PASSWD':None
}
......@@ -93,7 +93,10 @@ def getRedisValue(redis_key,key,conntype=None,oper='select'):
if __name__ == '__main__':
userUuid='00003a93-2a32-4501-b338-755b6cb1ec49'
#t=getRedisValue("order_product_graph:179240378044417")
t=getRedisValue('89',"*_same_product_batch_uuid*")
gid_redis='device_recall_mapping:'+"BC609876-4ED3-4514-BCB3-9649D066641B"
user_redis='user_recall_mapping:'+"1d0cdee1-85af-4e5b-856e-4a2e453befb6"
sku_batch="personal_recall_product:1657881287309234854"
t=getRedisValue('89',gid_redis,oper='delete') #,oper='delete'
print(t)
## search_fm_offline_feature:{md5(搜索词)}_query_offline
......
from recommend import *
def online_intent_cid3(uuid='-999999',gid='-999999'):
'''
:param uuid:
:param gid:
:return: 用户实时cid3
'''
recommend_user_intent_change_sql=recommend_user_intent_sql.format(uuid,gid)
df=execmysl('89',recommend_user_intent_change_sql)
if df.empty:
return []
return df['intent_cid3'].to_list()
def offine_intent_cid3(uuid='-999999',gid='-999999'):
cold_start_user_history_cid3_intentions_change_sql=cold_start_user_history_cid3_intentions_sql.format(uuid,gid)
df=execmysl('89',cold_start_user_history_cid3_intentions_change_sql)
if df.empty:
return []
return df['cid3'].to_list()[:3]
def dapan():
##大盘补足
timestamp=getRedisValue('89',cold_start_cid3_heat_intentions_timestamp_redis)
if not timestamp:
return []
dapan_redis=cold_start_cid3_heat_intentions_redis.format(timestamp.get(cold_start_cid3_heat_intentions_timestamp_redis))
dapan_cid3=getRedisValue('89',dapan_redis)
return dapan_cid3.get(dapan_redis)[:3]
def main(uuid='-999999',gid='-999999'):
online_cid3=online_intent_cid3(uuid,gid)
offline_cid3=offine_intent_cid3(uuid,gid)
dapan_cid3=dapan()
cid3s=removeRepeat(online_cid3+offline_cid3+dapan_cid3)[:3]
skus_df=concatSql(skuinfo_sql,**{"cid3":cid3s})
return skus_df['sku_no'].to_list()
if __name__ == '__main__':
uuid='6b4fe2b4-a851-40fe-b569-506bb93e6407'
#print(online_intent_cid3(uuid))
print(dapan())
......@@ -122,10 +122,24 @@ recommend_sku_query_match_info_sql="""
select * from online_recommend.recommend_sku_query_match_info
"""
####################################商品冷启动###############################################################
####用户历史意图表-商品冷启动
cold_start_user_history_cid3_intentions_sql="""
select * from cold_start_user_history_cid3_intentions unique_id={} order by rank
select * from offline_recommend.cold_start_user_history_cid3_intentions
where user_uuid='{}' or device_id='{}'
order by event_time desc limit 3
"""
###用户实时cid3意图表
recommend_user_intent_sql="""
select distinct aa.event_type,aa.intent_cid3 from nearline_recommend.recommend_user_intent aa join
(select user_uuid,event_type,MAX(create_time) as create_time from nearline_recommend.recommend_user_intent
where user_uuid='{}' or device_id='{}'
GROUP BY user_uuid,event_type limit 3)bb on aa.event_type=bb.event_type
and aa.create_time=bb.create_time and aa.user_uuid=bb.user_uuid
"""
###用户意图大盘补足
cold_start_cid3_heat_intentions_timestamp_redis="""cold_start_cid3_heat_intentions"""
cold_start_cid3_heat_intentions_redis="""cold_start_cid3_heat_intentions:{}"""
#########################################################################################################
\ No newline at end of file
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