This commit is contained in:
shenjian@fangjia.com
2023-03-09 16:06:55 +08:00
parent 57e5a5e649
commit 6688e93b99
+5 -22
View File
@@ -68,28 +68,6 @@ def build_doc(item):
return doc_dict
def update_status(new_df):
actions = list()
def deal(item):
action_doc = {
"_op_type": "update",
"_index": "bd_poi",
"_id": item['_id'],
"doc": {'status': 0}
}
actions.append(action_doc)
if len(actions) == 5000:
helpers.bulk(es206_client.elastic_client, actions)
actions.clear()
return item
new_df.apply(lambda x: deal(x), axis=1)
if len(actions) > 0:
helpers.bulk(es206_client.elastic_client, actions)
actions.clear()
def sync(city=None):
log.info("开始同步消费数据...")
# 【过期,无需状态】
@@ -130,7 +108,10 @@ def sync(city=None):
print(lng)
print(lat)
print(price)
print(index)
seaweed_df.loc[index, 'avg_cost'] = price
if item['_id'] == '50bd172ae4b0fbe60a6fe628':
print(seaweed_df.loc[index])
with ThreadPoolExecutor(max_workers=30) as pool:
for index, item in seaweed_df.iterrows():
pool.submit(find_around_price_item, index, item)
@@ -139,6 +120,8 @@ def sync(city=None):
actions = list()
count = 0
for index, item in seaweed_df.iterrows():
if item['_id'] == '50bd172ae4b0fbe60a6fe628':
print(item)
doc_info = build_doc(item)
action = {