From 5e3f9d60012c3ecae32426ead6ec5572c346edd0 Mon Sep 17 00:00:00 2001 From: "shenjian@fangjia.com" Date: Thu, 17 Nov 2022 17:25:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=88=B7=E5=9D=87=E6=80=BB?= =?UTF-8?q?=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/community/total_price.py | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/dags/business/business/community/total_price.py b/dags/business/business/community/total_price.py index ff8461a..3b6f867 100644 --- a/dags/business/business/community/total_price.py +++ b/dags/business/business/community/total_price.py @@ -25,9 +25,9 @@ def build_doc(item): return doc_dict -def avg_price_map_deal(x): - avg_price_map[x['city'] + x['region'] + x['name']] = x['avg_price'] - return x +# def avg_price_map_deal(x): +# avg_price_map[x['city'] + x['region'] + x['name']] = x['avg_price'] +# return x def deal(seaweed_df, index, item): @@ -45,14 +45,14 @@ def deal(seaweed_df, index, item): names.append(alias_item) # 户均总价 - if (curr_city + curr_region + curr_name) in avg_price_map: - avg_price = avg_price_map[curr_city + curr_region + curr_name] - if pd.notna(avg_price): + # if (curr_city + curr_region + curr_name) in avg_price_map: + # avg_price = avg_price_map[curr_city + curr_region + curr_name] + # if pd.notna(avg_price): # 由于覆盖率较低,暂不过滤 # min_avg_price = 0.8 * avg_price # max_avg_rice = 1.2 * avg_price - total_price = commutils.get_total_price(curr_city, curr_region, names, day_before=366) - seaweed_df.loc[index, 'total_price'] = total_price + total_price = commutils.get_total_price(curr_city, curr_region, names, day_before=366) + seaweed_df.loc[index, 'total_price'] = total_price def sync(city=None): @@ -64,12 +64,12 @@ def sync(city=None): seaweed_df = seaweed_df.reset_index(drop=True) # 加载库中均价数据 - query_sql = "SELECT city, region, name, avg_price FROM community_summary " - if pd.notna(city): - query_sql += " WHERE city='" + city + "' " - community_summary_df = es206_client.scan_by_sql_to_data_frame(query_sql) + # query_sql = "SELECT city, region, name, avg_price FROM community_summary " + # if pd.notna(city): + # query_sql += " WHERE city='" + city + "' " + # community_summary_df = es206_client.scan_by_sql_to_data_frame(query_sql) - community_summary_df.apply(lambda x: avg_price_map_deal(x), axis=1) + # community_summary_df.apply(lambda x: avg_price_map_deal(x), axis=1) with ThreadPoolExecutor(30) as pool: for index, item in seaweed_df.iterrows(): @@ -84,7 +84,8 @@ def sync(city=None): "_op_type": "update", "_index": index_name, "_id": item['_id'], - "doc": doc_info + "doc": doc_info, + "_retry_on_conflict": 5 } actions.append(action)