This commit is contained in:
parent
12ac93a584
commit
abe01828ab
16
app.py
16
app.py
|
|
@ -173,6 +173,7 @@ def calculate_statistics():
|
||||||
disqualified_lead_count = 0
|
disqualified_lead_count = 0
|
||||||
english_cold_lead_count = 0 # Field for English "cold lead" customers
|
english_cold_lead_count = 0 # Field for English "cold lead" customers
|
||||||
chinese_cold_lead_count = 0 # Field for Chinese "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
|
# Iterate over all customer data to calculate statistics
|
||||||
for customer in customer_data:
|
for customer in customer_data:
|
||||||
|
|
@ -180,8 +181,9 @@ def calculate_statistics():
|
||||||
if 'email addresses' in info and isinstance(info['email addresses'], list):
|
if 'email addresses' in info and isinstance(info['email addresses'], list):
|
||||||
for email in info['email addresses']:
|
for email in info['email addresses']:
|
||||||
total_emails += 1
|
total_emails += 1
|
||||||
|
category = email.get('category', '').lower()
|
||||||
# Count "cold lead" type
|
# Count "cold lead" type
|
||||||
if email.get('category', '').lower() == "cold lead":
|
if category == "cold lead":
|
||||||
cold_lead_count += 1
|
cold_lead_count += 1
|
||||||
# Check language-specific cold leads
|
# Check language-specific cold leads
|
||||||
language = email.get('language', 'en') # Default to English if language is absent or other
|
language = email.get('language', 'en') # Default to English if language is absent or other
|
||||||
|
|
@ -190,16 +192,18 @@ def calculate_statistics():
|
||||||
else:
|
else:
|
||||||
english_cold_lead_count += 1
|
english_cold_lead_count += 1
|
||||||
# Count "disqualified lead" type
|
# Count "disqualified lead" type
|
||||||
if email.get('category', '').lower() == "disqualified lead":
|
elif category == "disqualified lead":
|
||||||
disqualified_lead_count += 1
|
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
|
# Check if there is a promotion history
|
||||||
promotion_history = email.get('promotion history', [])
|
promotion_history = email.get('promotion history', [])
|
||||||
if not promotion_history: # If promotion history is empty or nonexistent
|
if not promotion_history: # If promotion history is empty or nonexistent
|
||||||
no_promotion_count += 1
|
no_promotion_count += 1
|
||||||
|
|
||||||
return (total_emails, cold_lead_count, no_promotion_count, disqualified_lead_count,
|
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/<int:index>')
|
@app.route('/customer/<int:index>')
|
||||||
|
|
@ -225,10 +229,9 @@ def view_customer(index):
|
||||||
is_first = index == 0
|
is_first = index == 0
|
||||||
is_last = index == len(customer_data) - 1
|
is_last = index == len(customer_data) - 1
|
||||||
|
|
||||||
# 调用统计函数,获取统计数据
|
|
||||||
# Call the statistics function
|
# Call the statistics function
|
||||||
(total_emails, cold_lead_count, no_promotion_count, disqualified_lead_count,
|
(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
|
# Call new function to count companies
|
||||||
company_count = count_companies()
|
company_count = count_companies()
|
||||||
|
|
@ -244,6 +247,7 @@ def view_customer(index):
|
||||||
disqualified_lead_count=disqualified_lead_count,
|
disqualified_lead_count=disqualified_lead_count,
|
||||||
english_cold_lead_count=english_cold_lead_count,
|
english_cold_lead_count=english_cold_lead_count,
|
||||||
chinese_cold_lead_count=chinese_cold_lead_count,
|
chinese_cold_lead_count=chinese_cold_lead_count,
|
||||||
|
other_lead_count=other_lead_count,
|
||||||
company_count=company_count)
|
company_count=company_count)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,8 @@
|
||||||
<div class="status-bar">
|
<div class="status-bar">
|
||||||
<p>Total Emails: {{ total_emails }} | Cold Leads: {{ cold_lead_count }} | No Promotion: {{ no_promotion_count }} |
|
<p>Total Emails: {{ total_emails }} | Cold Leads: {{ cold_lead_count }} | No Promotion: {{ no_promotion_count }} |
|
||||||
Disqualified Leads: {{ disqualified_lead_count }} | Total Companies: {{ company_count }} |
|
Disqualified Leads: {{ disqualified_lead_count }} | Total Companies: {{ company_count }} |
|
||||||
English Cold Leads: {{ english_cold_lead_count }} | Chinese Cold Leads: {{ chinese_cold_lead_count }}</p>
|
English Cold Leads: {{ english_cold_lead_count }} | Chinese Cold Leads: {{ chinese_cold_lead_count }} |
|
||||||
|
Other Leads: {{ other_lead_count }}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- JavaScript for navigation functions -->
|
<!-- JavaScript for navigation functions -->
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue