|
@@ -436,9 +436,12 @@ class TongCe:
|
|
|
def insert_into_rule(self):
|
|
|
option_info = self.options_info
|
|
|
insert_data = []
|
|
|
+ sub_question_ids = []
|
|
|
for key in option_info.keys():
|
|
|
data = option_info[key]
|
|
|
- insert_data.append([data[0], data[1], data[3]])
|
|
|
+ if data[3] not in sub_question_ids:
|
|
|
+ insert_data.append([data[0], data[1], data[3]])
|
|
|
+ sub_question_ids.append(data[3])
|
|
|
if len(insert_data) > 0:
|
|
|
self.linshi_db.truncate('mvp_page_display_rule')
|
|
|
self.linshi_db.add_some(self.sql_12, insert_data)
|
|
@@ -469,6 +472,10 @@ class TongCe:
|
|
|
rule = self.get_rule_data_info()
|
|
|
# 3: 读入答题数据
|
|
|
self.answers = self.marketing_db.select(self.sql_9)
|
|
|
+ # 4: 写入match信息
|
|
|
+ match_data = self.get_question_info_from_db()
|
|
|
+ self.linshi_db.truncate('mvp_page_display_match')
|
|
|
+ self.linshi_db.add_some(self.sql_3, match_data)
|
|
|
self.match_data_info = self.get_option_match_info()
|
|
|
|
|
|
# 筛选写入data的数据
|
|
@@ -486,9 +493,10 @@ class TongCe:
|
|
|
for qd in questions_data:
|
|
|
question_data_list.append([x for x in qd])
|
|
|
rule_id = self.get_rule_id(key, rule)
|
|
|
- if rule_id:
|
|
|
+ if rule_id is not None:
|
|
|
question_people = len(question_data_list)
|
|
|
if question_people > 0:
|
|
|
+ question_data_list.sort(key=lambda obj: obj[3])
|
|
|
for option_name, option_data_1 in groupby(question_data_list, key=lambda obj: obj[3]):
|
|
|
option_data_list = []
|
|
|
for od in option_data_1:
|
|
@@ -508,7 +516,6 @@ class TongCe:
|
|
|
for re in rule:
|
|
|
if str(re[3]) == str(sub_question_id):
|
|
|
return re[0]
|
|
|
- return None
|
|
|
|
|
|
def filter_people(self, city, age, zhifuli, juzhujiegou):
|
|
|
result = []
|
|
@@ -574,4 +581,4 @@ class TongCe:
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
tongce = TongCe()
|
|
|
- tongce.lingdi_data_scores()
|
|
|
+ tongce.insert_into_rule()
|