This commit is contained in:
parent
264a4428f8
commit
b40708d0ed
32
app.py
32
app.py
|
|
@ -86,6 +86,30 @@ def index():
|
|||
# 默认展示第一个客户
|
||||
return redirect(url_for('view_customer', index=0))
|
||||
|
||||
|
||||
|
||||
def calculate_statistics():
|
||||
total_emails = 0
|
||||
cold_lead_count = 0
|
||||
no_promotion_count = 0
|
||||
|
||||
# 遍历所有客户数据以计算统计信息
|
||||
for customer in customer_data:
|
||||
for domain, info in customer.items():
|
||||
if 'email addresses' in info and isinstance(info['email addresses'], list):
|
||||
for email in info['email addresses']:
|
||||
total_emails += 1
|
||||
# 判断 "cold lead" 类型
|
||||
if email.get('category', '').lower() == "cold lead":
|
||||
cold_lead_count += 1
|
||||
# 判断是否有推广历史
|
||||
promotion_history = email.get('promotion history', [])
|
||||
if not promotion_history: # 如果推广历史为空或不存在
|
||||
no_promotion_count += 1
|
||||
|
||||
return total_emails, cold_lead_count, no_promotion_count
|
||||
|
||||
|
||||
@app.route('/customer/<int:index>')
|
||||
def view_customer(index):
|
||||
# 判断是否有数据
|
||||
|
|
@ -109,11 +133,17 @@ def view_customer(index):
|
|||
is_first = index == 0
|
||||
is_last = index == len(customer_data) - 1
|
||||
|
||||
# 调用统计函数,获取统计数据
|
||||
total_emails, cold_lead_count, no_promotion_count = calculate_statistics()
|
||||
|
||||
return render_template('edit_customers.html',
|
||||
customer=customer,
|
||||
index=index,
|
||||
is_first=is_first,
|
||||
is_last=is_last)
|
||||
is_last=is_last,
|
||||
total_emails=total_emails,
|
||||
cold_lead_count=cold_lead_count,
|
||||
no_promotion_count=no_promotion_count)
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue