This commit is contained in:
parent
097e778eba
commit
90913c98cd
112
app.py
112
app.py
|
|
@ -89,60 +89,6 @@ def index():
|
||||||
return redirect(url_for('view_customer', index=0))
|
return redirect(url_for('view_customer', index=0))
|
||||||
|
|
||||||
|
|
||||||
# @app.route('/customer/<int:index>')
|
|
||||||
# def view_customer(index):
|
|
||||||
# # 判断是否有数据
|
|
||||||
# if not customer_data:
|
|
||||||
# return "No customer data provided.", 400
|
|
||||||
|
|
||||||
# # 确保 index 在合法范围内
|
|
||||||
# if index < 0 or index >= len(customer_data):
|
|
||||||
# return "Index out of range.", 400
|
|
||||||
|
|
||||||
# customer = customer_data[index]
|
|
||||||
|
|
||||||
# # 为每个 email addresses 列表中的项添加唯一的索引
|
|
||||||
# for domain, info in customer.items():
|
|
||||||
# if 'email addresses' in info and isinstance(info['email addresses'], list):
|
|
||||||
# for email_idx, email in enumerate(info['email addresses']):
|
|
||||||
# email['idx'] = email_idx # 给每个 email 项添加唯一的索引
|
|
||||||
|
|
||||||
# # 添加统计逻辑
|
|
||||||
# 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
|
|
||||||
|
|
||||||
# is_first = index == 0
|
|
||||||
# is_last = index == len(customer_data) - 1
|
|
||||||
|
|
||||||
# # 将统计信息和原有数据一起传递到模板
|
|
||||||
# return render_template('edit_customers.html',
|
|
||||||
# customer=customer,
|
|
||||||
# index=index,
|
|
||||||
# is_first=is_first,
|
|
||||||
# is_last=is_last,
|
|
||||||
# total_emails=total_emails,
|
|
||||||
# cold_lead_count=cold_lead_count,
|
|
||||||
# no_promotion_count=no_promotion_count)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/customer/<int:index>')
|
@app.route('/customer/<int:index>')
|
||||||
def view_customer(index):
|
def view_customer(index):
|
||||||
# 判断是否有数据
|
# 判断是否有数据
|
||||||
|
|
@ -163,14 +109,70 @@ def view_customer(index):
|
||||||
for email_idx, email in enumerate(info['email addresses']):
|
for email_idx, email in enumerate(info['email addresses']):
|
||||||
email['idx'] = email_idx # 给每个 email 项添加唯一的索引
|
email['idx'] = email_idx # 给每个 email 项添加唯一的索引
|
||||||
|
|
||||||
|
# 统计数据的计算
|
||||||
|
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
|
||||||
|
|
||||||
is_first = index == 0
|
is_first = index == 0
|
||||||
is_last = index == len(customer_data) - 1
|
is_last = index == len(customer_data) - 1
|
||||||
|
|
||||||
|
# 将统计信息和原有数据一起传递到模板
|
||||||
return render_template('edit_customers.html',
|
return render_template('edit_customers.html',
|
||||||
customer=customer,
|
customer=customer,
|
||||||
index=index,
|
index=index,
|
||||||
is_first=is_first,
|
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)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# @app.route('/customer/<int:index>')
|
||||||
|
# def view_customer(index):
|
||||||
|
# # 判断是否有数据
|
||||||
|
# if not customer_data:
|
||||||
|
# return "No customer data provided.", 400
|
||||||
|
|
||||||
|
# # 确保 index 在合法范围内
|
||||||
|
# if index < 0 or index >= len(customer_data):
|
||||||
|
# return "Index out of range.", 400
|
||||||
|
|
||||||
|
# customer = customer_data[index]
|
||||||
|
|
||||||
|
# # 为每个 email addresses 列表中的项添加唯一的索引
|
||||||
|
# for domain, info in customer.items():
|
||||||
|
# print(f"..........domain={domain}")
|
||||||
|
# print(f"..........info={info}")
|
||||||
|
# if 'email addresses' in info and isinstance(info['email addresses'], list):
|
||||||
|
# for email_idx, email in enumerate(info['email addresses']):
|
||||||
|
# email['idx'] = email_idx # 给每个 email 项添加唯一的索引
|
||||||
|
|
||||||
|
# is_first = index == 0
|
||||||
|
# is_last = index == len(customer_data) - 1
|
||||||
|
|
||||||
|
# return render_template('edit_customers.html',
|
||||||
|
# customer=customer,
|
||||||
|
# index=index,
|
||||||
|
# is_first=is_first,
|
||||||
|
# is_last=is_last)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue