新增城市范围圈定

This commit is contained in:
shenjian@fangjia.com
2023-03-10 09:30:13 +08:00
parent ccc566f6d1
commit 437bb336bd
@@ -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():