优化同步过程中小区变更问题
This commit is contained in:
@@ -6,7 +6,7 @@ import pandas as pd
|
||||
from goojia_utils import MAIN_MONGO_CLIENT, ElasticSearchClient, commutils, dateutils, areautils
|
||||
from elasticsearch import helpers
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
import datetime
|
||||
import re
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
seaweed_conn = MAIN_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
|
||||
@@ -28,8 +28,7 @@ def sync(city=None):
|
||||
seaweed_query = {'cat': 'district', 'status': 0}
|
||||
if pd.notna(city):
|
||||
seaweed_query['city'] = city
|
||||
seaweed_df = pd.DataFrame(
|
||||
list(seaweed_conn.find(seaweed_query, {'city': 1, 'region': 1, 'name': 1, 'alias': 1}).batch_size(100000)))
|
||||
seaweed_df = pd.read_csv('/opt/airflow/dags/repo/dags/business/community/data/seaweed.csv', sep='@', encoding='UTF-8')
|
||||
|
||||
# 加载库中均价数据
|
||||
query_sql = "SELECT city, region, name, avg_price FROM community_summary "
|
||||
@@ -53,9 +52,12 @@ def sync(city=None):
|
||||
curr_region = item['region']
|
||||
curr_name = item['name']
|
||||
names = [curr_name]
|
||||
if type(item['alias']) == list:
|
||||
for alias_item in item['alias']:
|
||||
names.append(alias_item)
|
||||
|
||||
if pd.notna(item['alias']) and '[]' != item['alias']:
|
||||
alias_list = re.sub("\[|\]|'", '', item['alias']).split(',')
|
||||
if len(alias_list) > 0:
|
||||
for alias_item in alias_list:
|
||||
names.append(alias_item)
|
||||
|
||||
# 户均总价
|
||||
if (curr_city + curr_region + curr_name) in avg_price_map:
|
||||
@@ -63,13 +65,13 @@ def sync(city=None):
|
||||
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=93, min_avg_price=min_avg_price, max_avg_price=max_avg_rice)
|
||||
total_price = commutils.get_total_price(curr_city, curr_region, names, day_before=366, min_avg_price=min_avg_price, max_avg_price=max_avg_rice)
|
||||
seaweed_df.loc[index, 'total_price'] = total_price
|
||||
|
||||
for index, item in seaweed_df.iterrows():
|
||||
pool.submit(deal, index, item)
|
||||
|
||||
seaweed_df['_id'] = seaweed_df['_id'].astype(str)
|
||||
|
||||
|
||||
actions = list()
|
||||
count = 0
|
||||
|
||||
Reference in New Issue
Block a user