diff --git a/dags/business/business/community/consumption_stat.py b/dags/business/business/community/consumption_stat.py index d6ba3ed..dc00b99 100644 --- a/dags/business/business/community/consumption_stat.py +++ b/dags/business/business/community/consumption_stat.py @@ -34,19 +34,29 @@ def calculate_confidence(row): def stat(city): - community_summary_df = es206_client.scan_to_data_frame(query={"query": { - "bool": { - "must": [ - { - "term": { - "city": { - "value": city + if pd.notna(city): + query = { + "bool": { + "must": [ + { + "terms": { + "city": [city] } } - } - ] + ] + } } - }}, source=[ + else: + query = { + "bool": { + "must": [ + { + "match_all": {} + } + ] + } + } + community_summary_df = es206_client.scan_to_data_frame(query={"query": query}, source=[ "city", "region", "consumption_rating", @@ -110,19 +120,29 @@ def detail(city): """ 计算消费潜力 """ - community_summary_df = es206_client.scan_to_data_frame(query={"query": { + if pd.notna(city): + query = { "bool": { - "must": [ - { - "term": { - "city": { - "value": city + "must": [ + { + "terms": { + "city": [city] + } } - } - } - ] + ] } - }}, source=[ + } + else: + query = { + "bool": { + "must": [ + { + "match_all": {} + } + ] + } + } + community_summary_df = es206_client.scan_to_data_frame(query={"query": query}, source=[ "id", "city", "region",