From d183ca5c6cf3c7a9f96f4ea4e42c935a330dc1ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Tue, 8 Apr 2025 17:51:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=85=A8=E9=87=8F=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/community/consumption_stat.py | 60 ++++++++++++------- 1 file changed, 40 insertions(+), 20 deletions(-) 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",