SUMANA SUMANAKUL (ING) commited on
Commit
f30514b
·
1 Parent(s): f481e43
app_p/handler/recommendation_handler.py CHANGED
@@ -84,6 +84,7 @@ def generate_recommendation_from_profile(
84
  all_persona_products = []
85
  for tier_fallback in matched_persona.get('recommendations_by_salary', []):
86
  all_persona_products.extend(tier_fallback.get('products', []))
 
87
 
88
  gender_filtered_products = [p for p in all_persona_products if p.get('gender') == 'all' or p.get('gender') == gender]
89
  final_filtered_products = [p for p in gender_filtered_products if p.get('insurance_type') == target_insurance_type]
@@ -108,8 +109,12 @@ def generate_recommendation_from_profile(
108
 
109
 
110
  # 6. จัดกลุ่มและเตรียมข้อมูลสำหรับส่งคืน
111
- main_plans = [p for p in products_to_recommend if p.get('plan_type') == 'Basic']
112
- riders = [p for p in products_to_recommend if p.get('plan_type') == 'Rider']
 
 
 
 
113
 
114
  main_plans_str = "ไม่มีแผนประกันหลักที่แนะนำ"
115
  if main_plans:
 
84
  all_persona_products = []
85
  for tier_fallback in matched_persona.get('recommendations_by_salary', []):
86
  all_persona_products.extend(tier_fallback.get('products', []))
87
+ # print(all_persona_products)
88
 
89
  gender_filtered_products = [p for p in all_persona_products if p.get('gender') == 'all' or p.get('gender') == gender]
90
  final_filtered_products = [p for p in gender_filtered_products if p.get('insurance_type') == target_insurance_type]
 
109
 
110
 
111
  # 6. จัดกลุ่มและเตรียมข้อมูลสำหรับส่งคืน
112
+ main_plans_pre = [p for p in products_to_recommend if p.get('plan_type') == 'Basic']
113
+ main_plans = [dict(t) for t in {tuple(d.items()) for d in main_plans_pre}]
114
+ riders_pre = [p for p in products_to_recommend if p.get('plan_type') == 'Rider']
115
+ riders = [dict(t) for t in {tuple(d.items()) for d in riders_pre}]
116
+
117
+ print(main_plans)
118
 
119
  main_plans_str = "ไม่มีแผนประกันหลักที่แนะนำ"
120
  if main_plans:
config/personas.json CHANGED
@@ -112,7 +112,7 @@
112
  "plan_type": "Basic",
113
  "product_category": "Protection + Saving",
114
  "gender": "all",
115
- "product_description": "ชำระเบี้ยสั้นๆ เพียง 5 ปี แต่ให้ความคุ้มครองนาน 14 ปี พร้อมรับเงินคืนทุกปี ปีละ 5% และรับเงินครบสัญญา 210% สามารถใช้สิทธิลดหย่อนภาษีได้",
116
  "insurance_type": "ประกันเพื่อการลงทุน"
117
  }
118
  ]
@@ -264,7 +264,7 @@
264
  "plan_type": "Basic",
265
  "product_category": "Protection + Saving",
266
  "gender": "all",
267
- "product_description": "ชำระเบี้ยสั้นๆ เพียง 5 ปี แต่ให้ความคุ้มครองนาน 14 ปี พร้อมรับเงินคืนทุกปี ปีละ 5% และรับเงินครบสัญญา 210%",
268
  "insurance_type": "ประกันเพื่อการลงทุน"
269
  }
270
  ]
@@ -295,7 +295,7 @@
295
  "plan_type": "Basic",
296
  "product_category": "Protection + Saving",
297
  "gender": "all",
298
- "product_description": "ชำระเบี้ยสั้นๆ เพียง 5 ปี แต่ให้ความคุ้มครองนาน 14 ปี พร้อมรับเงินคืนทุกปี ปีละ 5% และรับเงินครบสัญญา 210%",
299
  "insurance_type": "ประกันเพื่อการลงทุน"
300
  }
301
  ]
 
112
  "plan_type": "Basic",
113
  "product_category": "Protection + Saving",
114
  "gender": "all",
115
+ "product_description": "ชำระเบี้ยสั้นๆ เพียง 5 ปี แต่ให้ความคุ้มครองนาน 14 ปี พร้อมรับเงินคืนทุกปี ปีละ 5% และรับเงินครบสัญญา 260% สามารถใช้สิทธิลดหย่อนภาษีได้",
116
  "insurance_type": "ประกันเพื่อการลงทุน"
117
  }
118
  ]
 
264
  "plan_type": "Basic",
265
  "product_category": "Protection + Saving",
266
  "gender": "all",
267
+ "product_description": "ชำระเบี้ยสั้นๆ เพียง 5 ปี แต่ให้ความคุ้มครองนาน 14 ปี พร้อมรับเงินคืนทุกปี ปีละ 5% และรับเงินครบสัญญา 260%",
268
  "insurance_type": "ประกันเพื่อการลงทุน"
269
  }
270
  ]
 
295
  "plan_type": "Basic",
296
  "product_category": "Protection + Saving",
297
  "gender": "all",
298
+ "product_description": "ชำระเบี้ยสั้นๆ เพียง 5 ปี แต่ให้ความคุ้มครองนาน 14 ปี พร้อมรับเงินคืนทุกปี ปีละ 5% และรับเงินครบสัญญา 260%",
299
  "insurance_type": "ประกันเพื่อการลงทุน"
300
  }
301
  ]