优化全量统计

This commit is contained in:
沈健
2025-04-08 17:51:45 +08:00
parent c936b2c2c5
commit d183ca5c6c
@@ -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",