Commit 9bb6effc authored by litaolemo's avatar litaolemo

update

parent bfc6196c
This diff is collapsed.
......@@ -186,7 +186,7 @@ def get_device_num_from_es(word):
return tractate_content_num
def get_tractate_tags_from_es(doc_id):
def get_tractate_tags_from_es(doc_id,id_type='tractate'):
# print(doc_id)
body = {
"query": {
......@@ -197,6 +197,7 @@ def get_tractate_tags_from_es(doc_id):
}
}
}
if id_type == 'tractate':
# tractate
results = es.search(
index='gm-dbmw-tractate-read',
......@@ -205,6 +206,13 @@ def get_tractate_tags_from_es(doc_id):
body=body
)
# print(results)
elif id_type == 'diary':
results = es.search(
index='gm-dbmw-diary-read',
doc_type='diary',
timeout='10s',
body=body
)
return results["hits"]['hits'][0]
......@@ -365,3 +373,34 @@ def get_user_post_from_mysql(sql):
tags_v3_card_id_list.append(int(card_id[0]))
# print(card_id_list)
return second_demands_count_dict, tags_v3_count_dict, second_demands_card_id_list,tags_v3_card_id_list,second_demands_tractate_dict,tags_v3_tractate_dict
def get_diary_from_mysql(sql,id_type='tractate'):
second_demands_card_id_list = []
tags_v3_card_id_list = []
second_demands_count_dict = {}
tags_v3_count_dict = {}
second_demands_tractate_dict = {}
tags_v3_tractate_dict = {}
sql_res = con_sql_doris_prod(sql)
for card_id in sql_res:
# print(type(card_id[0]),card_id)
es_res = get_tractate_tags_from_es(card_id[0],id_type='diary')
second_demands_tractate_dict[card_id[0]] = es_res["_source"]["second_demands"]
tags_v3_tractate_dict[card_id[0]] = es_res["_source"]["tags_v3"]
for position in es_res["_source"]["second_demands"]:
if position in second_demands_count_dict:
second_demands_count_dict[position] += 1
else:
second_demands_count_dict[position] = 1
second_demands_card_id_list.append(int(card_id[0]))
for tag in es_res["_source"]["tags_v3"]:
if tag in tags_v3_count_dict:
tags_v3_count_dict[tag] += 1
else:
tags_v3_count_dict[tag] = 1
tags_v3_card_id_list.append(int(card_id[0]))
# print(card_id_list)
return second_demands_count_dict, tags_v3_count_dict, second_demands_card_id_list,tags_v3_card_id_list,second_demands_tractate_dict,tags_v3_tractate_dict
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