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():