This commit is contained in:
shenjian@fangjia.com
2022-10-28 19:13:23 +08:00
parent 60e297f2f5
commit c3d3d69533
@@ -55,12 +55,17 @@ def build_doc(item):
return doc_dict
def sync():
def sync(city=None):
log.info("开始同步相对价格排名数据...")
seaweed_df = pd.read_csv(path + '/seaweed.csv', sep='@', encoding='UTF-8')
if pd.notna(city):
seaweed_df = seaweed_df[seaweed_df['city'] == city].copy()
seaweed_df = seaweed_df.reset_index()
def find_around_price_item(index, item):
if index % 1000 == 0:
log.info("已处理" + str(index))
if 'lng' not in item:
return
lng = commutils.format_lat_lng(item['lng'])
@@ -73,7 +78,7 @@ def sync():
elif len(around_seaweed_df) == 1:
seaweed_df.loc[index, 'relative_price_ranking'] = 0.5
with ThreadPoolExecutor(max_workers=50) as pool:
with ThreadPoolExecutor(max_workers=30) as pool:
for index, item in seaweed_df.iterrows():
pool.submit(find_around_price_item, index, item)