diff --git a/app.py b/app.py index 357a34b..863b69d 100644 --- a/app.py +++ b/app.py @@ -173,6 +173,7 @@ def calculate_statistics(): disqualified_lead_count = 0 english_cold_lead_count = 0 # Field for English "cold lead" customers chinese_cold_lead_count = 0 # Field for Chinese "cold lead" customers + other_lead_count = 0 # New field for other leads (not cold or disqualified) # Iterate over all customer data to calculate statistics for customer in customer_data: @@ -180,8 +181,9 @@ def calculate_statistics(): if 'email addresses' in info and isinstance(info['email addresses'], list): for email in info['email addresses']: total_emails += 1 + category = email.get('category', '').lower() # Count "cold lead" type - if email.get('category', '').lower() == "cold lead": + if category == "cold lead": cold_lead_count += 1 # Check language-specific cold leads language = email.get('language', 'en') # Default to English if language is absent or other @@ -190,16 +192,18 @@ def calculate_statistics(): else: english_cold_lead_count += 1 # Count "disqualified lead" type - if email.get('category', '').lower() == "disqualified lead": + elif category == "disqualified lead": disqualified_lead_count += 1 + # Count emails that are neither "cold lead" nor "disqualified lead" + else: + other_lead_count += 1 # Check if there is a promotion history promotion_history = email.get('promotion history', []) if not promotion_history: # If promotion history is empty or nonexistent no_promotion_count += 1 return (total_emails, cold_lead_count, no_promotion_count, disqualified_lead_count, - english_cold_lead_count, chinese_cold_lead_count) - + english_cold_lead_count, chinese_cold_lead_count, other_lead_count) @app.route('/customer/') @@ -225,10 +229,9 @@ def view_customer(index): is_first = index == 0 is_last = index == len(customer_data) - 1 - # 调用统计函数,获取统计数据 # Call the statistics function (total_emails, cold_lead_count, no_promotion_count, disqualified_lead_count, - english_cold_lead_count, chinese_cold_lead_count) = calculate_statistics() + english_cold_lead_count, chinese_cold_lead_count, other_lead_count) = calculate_statistics() # Call new function to count companies company_count = count_companies() @@ -244,6 +247,7 @@ def view_customer(index): disqualified_lead_count=disqualified_lead_count, english_cold_lead_count=english_cold_lead_count, chinese_cold_lead_count=chinese_cold_lead_count, + other_lead_count=other_lead_count, company_count=company_count) diff --git a/templates/edit_customers.html b/templates/edit_customers.html index 2003f0e..e782f61 100644 --- a/templates/edit_customers.html +++ b/templates/edit_customers.html @@ -86,7 +86,8 @@

Total Emails: {{ total_emails }} | Cold Leads: {{ cold_lead_count }} | No Promotion: {{ no_promotion_count }} | Disqualified Leads: {{ disqualified_lead_count }} | Total Companies: {{ company_count }} | - English Cold Leads: {{ english_cold_lead_count }} | Chinese Cold Leads: {{ chinese_cold_lead_count }}

+ English Cold Leads: {{ english_cold_lead_count }} | Chinese Cold Leads: {{ chinese_cold_lead_count }} | + Other Leads: {{ other_lead_count }}