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

新增可控制台执行的ab耗时脚本

parent 7f7db97f
...@@ -33,10 +33,16 @@ mysql_info={ ...@@ -33,10 +33,16 @@ mysql_info={
"host":"172.29.5.16", "host":"172.29.5.16",
"port":"3306" "port":"3306"
}, },
"27":{ "8066_27":{
"name":"real_data_test", "name":"real_data_test",
"pwd":"qpRBSarm$Tv*YO!n", "pwd":"qpRBSarm$Tv*YO!n",
"host":"172.30.5.27", "host":"172.30.5.27",
"port":"8066" "port":"8066"
},
"7438_27":{
"name":"xyqb_recommender_system_w",
"pwd":"Qa6pxybKE8KgsUGV",
"host":"172.30.5.27",
"port":"7438"
} }
} }
from databaseConn import *
...@@ -32,7 +32,9 @@ def mysql_universal(namespace): ...@@ -32,7 +32,9 @@ def mysql_universal(namespace):
mysql_universal="mysql://{name}:{pwd}@{host}:{port}" mysql_universal="mysql://{name}:{pwd}@{host}:{port}"
mysql_info=mysqlInfo(namespace) mysql_info=mysqlInfo(namespace)
#print(mysql_info) #print(mysql_info)
return create_engine(mysql_universal.format(**mysql_info)) temp=create_engine(mysql_universal.format(**mysql_info))
print("mysql连接信息:",temp)
return temp
def execmysl(namespace,sql): def execmysl(namespace,sql):
if 'select' not in sql or 'from' not in sql: if 'select' not in sql or 'from' not in sql:
...@@ -68,4 +70,4 @@ def concatSql(sql,**kwargs): ...@@ -68,4 +70,4 @@ def concatSql(sql,**kwargs):
return sql+' where '+temp[:-4] return sql+' where '+temp[:-4]
if __name__ == '__main__': if __name__ == '__main__':
print(execmysl(119,'update 1')) print(execmysl('qa',"select sku_name from kdsp.t_sku_info where sku_name like '%%口红%%'"))
\ No newline at end of file \ No newline at end of file
...@@ -84,7 +84,7 @@ def getRedisValue(key,conntype=None,oper='select'): ...@@ -84,7 +84,7 @@ def getRedisValue(key,conntype=None,oper='select'):
if __name__ == '__main__': if __name__ == '__main__':
userUuid='00003a93-2a32-4501-b338-755b6cb1ec49' userUuid='00003a93-2a32-4501-b338-755b6cb1ec49'
t=getRedisValue("search_fm_offline_feature:cd11201d3e789c63_query_offline") t=getRedisValue("same_product_batch_uuid")
print(t) print(t)
## search_fm_offline_feature:{md5(搜索词)}_query_offline ## search_fm_offline_feature:{md5(搜索词)}_query_offline
......
...@@ -6,5 +6,6 @@ from tools.listOperation import * ...@@ -6,5 +6,6 @@ from tools.listOperation import *
from databaseConn.mysqlOperation import * from databaseConn.mysqlOperation import *
from databaseConn.redisOperation import * from databaseConn.redisOperation import *
from recommend.publicSql import * from recommend.publicSql import *
cur_dir=os.path.dirname(os.path.abspath(__file__)) cur_dir=os.path.dirname(os.path.abspath(__file__))
file_path=os.path.join(cur_dir,'tempFile') file_path=os.path.join(cur_dir,'tempFile')
from recommend import *
from recommend.publicFunc import skuinfo,dapanBu
def preconditions(uuid):
'''
:param uuid:
:return: 判断上批次是否为加购topic,是则不触发,不是才触发
'''
back_batch_redis=""
return True
def recall_J1(skuno):
'''
:param skuno:
:return: 将所有的数据都召回,然后进行去重并选取100
'''
# graph_change_sql=concatSql(graph_relation_sql,**{"sku1_id":skuno})
# graph_df=execmysl('7438_27',graph_change_sql)
# temp= graph_df.sort_values(by='rank')['sku2_id'].to_list()[:100]
# if len(set(100))>100:
# return removeRepeat(temp)[:100]
# als_change_sql1=concatSql(als_sql,**{"product_id1":skuno})
# als_df1=execmysl('7438_27',als_change_sql1)
# temp+=als_df1.sort_values(by='rank')['product_id2'].to_list()
# als_change_sql2=concatSql(als_sql,**{"product_id2":skuno})
# als_df2=execmysl('7438_27',als_change_sql1)
# temp+=als_df2.sort_values(by='rank')['product_id1'].to_list()
# return removeRepeat(temp)[:100]
temp=[]
graph_change_redis=graph_redis.format(sku_no=skuno)
graph_date=getRedisValue(graph_change_redis).get(graph_change_redis)
als_change_redis=als_redis.format(sku_no=skuno)
als_date=getRedisValue(als_change_redis).get(als_change_redis)
temp+=graph_date
temp+=als_date
temp+=supply_J1(skuno)
return temp
def supply_J1(skuno):
sku_info=skuinfo(skuno)
dapan_change_sql=concatSql(dapan_sql,**{"cid3":sku_info.get('cid3')})
dapan_df=execmysl('7438_27',dapan_change_sql)
temp=dapan_df[dapan_df['brand_name']!=sku_info.get('brand_name')]['sku_no'].to_list()
temp=removeRepeat(temp)[:50]
dapan_change1_sql=concatSql(dapan_sql,**{"brand_name":sku_info.get('brand_name')})
dapan1_df=execmysl('7438_27',dapan_change1_sql)
temp+=dapan_df[dapan_df['cid3']!=sku_info.get('cid3')]['sku_no'].to_list()
return removeRepeat(temp)[:100]
def recall_J2():
pass
def recall_J3():
return dapanBu()
if __name__ == '__main__':
print(recall_J1('12312'))
...@@ -206,7 +206,14 @@ def concatCondition(seedData,contype='jg'): ...@@ -206,7 +206,14 @@ def concatCondition(seedData,contype='jg'):
conditions.append({'condition':condition7,'by':'score_brand'}) conditions.append({'condition':condition7,'by':'score_brand'})
return conditions return conditions
def dapanBu():
'''
:return: 获取当前大盘批次,然后拼接redis,拿到大盘数据
'''
cur_dapan_redis="same_product_batch_uuid"
batch=getRedisValue(cur_dapan_redis).get(cur_dapan_redis)
dapan_redis=cur_dapan_redis+":"+str(batch)
return getRedisValue(dapan_redis).get(dapan_redis)
def jgDapanBu(): def jgDapanBu():
...@@ -238,7 +245,7 @@ if __name__ == '__main__': ...@@ -238,7 +245,7 @@ if __name__ == '__main__':
# #change_sql=concatSql(jd_hot_sql,) # #change_sql=concatSql(jd_hot_sql,)
# t=normalClickTopic(sku_no,change_sql) # t=normalClickTopic(sku_no,change_sql)
# print(t) # print(t)
print(concatCondition(skus)) print(dapanBu())
......
...@@ -48,3 +48,26 @@ jg_purpost_all_sql=""" ...@@ -48,3 +48,26 @@ jg_purpost_all_sql="""
select * from where cid3={} or cid2={} or cid1={} or brand_name='{}' select * from where cid3={} or cid2={} or cid1={} or brand_name='{}'
""" """
#图关联表
graph_redis="""
product_graph:{sku_no}
"""
graph_relation_sql="""
select * from xyqb_recommender_system.mix_products_graph
"""
##ALS相关表
als_redis="""
product_correlation:{sku_no}
"""
als_sql="""
select * from xyqb_recommender_system.mix_products_correlation
"""
dapan_hot_sql="""
select * from
xyqb_recommender_system.kdsp_same_ranked_list
"""
##获取上一批次记录后,再去mysql批次表里拿数据
back_batch_redis="""
recommend_recall:{uuid}:{sku_no}
"""
No preview for this file type
This diff is collapsed.
from databaseConn.mysqlOperation import * from databaseConn.mysqlOperation import *
from recommend.publicSql import * from recommend.publicSql import *
from databaseConn import * from databaseConn import *
\ No newline at end of file
dapan_sql
\ No newline at end of file
import requests import requests
from search.abSearch import totalrun from search.abSearch_script import totalrun
from tools import * from tools import *
from tools.publicFun import genUuidDeviceid from tools.publicFun import genUuidDeviceid
from tools.fileOperation import * from tools.fileOperation import *
......
...@@ -5,7 +5,7 @@ def genUuidDeviceid(): ...@@ -5,7 +5,7 @@ def genUuidDeviceid():
:return: :return:
""" """
uuid,deviced=codeuuid.uuid4().urn.split(':')[-1],codeuuid.uuid4().urn.split(':')[-1] uuid,deviced=codeuuid.uuid4().urn.split(':')[-1],codeuuid.uuid4().urn.split(':')[-1]
uuid='c1d7ff4e-ee78-48de-8b8d-50c2af29c3ff' uuid='c0c27ffb-f2da-4650-8855-2da2191ce772'
deviced='guiqiuyue_'+str(deviced) deviced='guiqiuyue_'+str(deviced)
return uuid,deviced return uuid,deviced
......
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