From 437bb336bd2dda2a831c956c6b805ee874e35ec1 Mon Sep 17 00:00:00 2001 From: "shenjian@fangjia.com" Date: Fri, 10 Mar 2023 09:30:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=9F=8E=E5=B8=82=E8=8C=83?= =?UTF-8?q?=E5=9B=B4=E5=9C=88=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../community/relative_price_ranking.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/dags/business/business/community/relative_price_ranking.py b/dags/business/business/community/relative_price_ranking.py index 8c0e2ac..caf16ea 100644 --- a/dags/business/business/community/relative_price_ranking.py +++ b/dags/business/business/community/relative_price_ranking.py @@ -18,7 +18,7 @@ path = "/home/airflow/data/community" m_date = dateutils.iso_format() mutex = Lock() -def find_around_seaweed(lng, lat): +def find_around_seaweed(city_now, lng, lat): """ 查找周边均价 """ @@ -29,6 +29,13 @@ def find_around_seaweed(lng, lat): "query": { "bool": { "filter": [ + { + "term": { + "city": { + "value": city_now + } + } + }, { "range": { "avg_price": { @@ -72,7 +79,8 @@ def sync(city=None): lng = commutils.format_lat_lng(item['lng']) lat = commutils.format_lat_lng(item['lat']) if pd.notna(lng): - around_seaweed_df = find_around_seaweed(lng, lat) + city_now = item['city'] + around_seaweed_df = find_around_seaweed(city_now, lng, lat) mutex.acquire(timeout=60) if len(around_seaweed_df) > 1: around_seaweed_df['relative_price_ranking'] = around_seaweed_df['avg_price'].rank(pct=True) @@ -81,10 +89,13 @@ def sync(city=None): seaweed_df.loc[index, 'relative_price_ranking'] = 0.5 mutex.release() - with ThreadPoolExecutor(max_workers=20) as pool: + with ThreadPoolExecutor(max_workers=30) as pool: for index, item in seaweed_df.iterrows(): pool.submit(find_around_price_item, index, item) + # for index, item in seaweed_df.iterrows(): + # find_around_price_item(index, item) + actions = list() count = 0 for index, item in seaweed_df.iterrows():