From c5fad0da543b3ee9480f5475805bd9333e1db01a Mon Sep 17 00:00:00 2001 From: hailin Date: Mon, 28 Oct 2024 15:10:52 +0800 Subject: [PATCH] . --- app.py | 24 +++++++++++++++++++++--- templates/edit_customers.html | 18 ++++++++++++++++++ 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index 2be5c24..ceb64ca 100644 --- a/app.py +++ b/app.py @@ -88,6 +88,7 @@ def index(): # 默认展示第一个客户 return redirect(url_for('view_customer', index=0)) + @app.route('/customer/') def view_customer(index): # 判断是否有数据 @@ -102,20 +103,35 @@ def view_customer(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 项添加唯一的索引 + # 添加统计逻辑 + total_emails = 0 + cold_lead_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 + 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) + is_last=is_last, + total_emails=total_emails, + cold_lead_count=cold_lead_count) # @app.route('/customer/') # def view_customer(index): @@ -146,6 +162,8 @@ def view_customer(index): # is_first=is_first, # is_last=is_last) + + @app.route('/update/', methods=['POST']) def update_customers(index): updated_data = request.form.to_dict(flat=False) diff --git a/templates/edit_customers.html b/templates/edit_customers.html index 795bdce..60be372 100644 --- a/templates/edit_customers.html +++ b/templates/edit_customers.html @@ -4,6 +4,19 @@ Edit Customer Data +

Edit Customer Data

@@ -67,6 +80,11 @@ + +
+

Total Emails: {{ total_emails }} | Cold Leads: {{ cold_lead_count }}

+
+