|
@@ -149,40 +149,14 @@ class Mvp:
|
|
|
'''
|
|
|
|
|
|
# 根据用户uuid获取城市信息
|
|
|
- sql_16 = '''
|
|
|
- SELECT
|
|
|
- a.uuid,
|
|
|
- b.sub_option_content
|
|
|
- FROM
|
|
|
- f_t_daren_score_2 a
|
|
|
- LEFT JOIN d_shangju_tiku_02 b ON a.testcase_id = b.testcase_id
|
|
|
- WHERE
|
|
|
- a.sub_question_id = b.sub_question_id
|
|
|
- AND (
|
|
|
- a.score = b.score
|
|
|
- OR a.score = b.sub_option_id
|
|
|
- )
|
|
|
- AND a.uuid = %s
|
|
|
- AND a.sub_question_id = 303 and a.status = b.status = 1
|
|
|
- '''
|
|
|
+ sql_16 = 'SELECT a.uuid, b.sub_option_content FROM f_t_daren_score_2 a LEFT JOIN d_shangju_tiku_02 b ON ' \
|
|
|
+ 'a.testcase_id = b.testcase_id WHERE a.sub_question_id = b.sub_question_id AND (a.score = b.score OR ' \
|
|
|
+ 'a.score = b.sub_option_id) AND a.uuid = %sAND a.sub_question_id = 303 and a.status = b.status = 1 '
|
|
|
|
|
|
# 答题人人群分类信息
|
|
|
- sql_17 = ''''
|
|
|
- SELECT
|
|
|
- a.uuid,
|
|
|
- b.sub_option_id
|
|
|
- FROM
|
|
|
- f_t_daren_score_2 a
|
|
|
- LEFT JOIN d_shangju_tiku_02 b ON a.testcase_id = b.testcase_id
|
|
|
- WHERE
|
|
|
- a.sub_question_id = b.sub_question_id
|
|
|
- AND (
|
|
|
- a.score = b.score
|
|
|
- OR a.score = b.sub_option_id
|
|
|
- )
|
|
|
- AND a.uuid = %s
|
|
|
- AND a.sub_question_id = 286 and a.status = b.status = 1
|
|
|
- '''
|
|
|
+ sql_17 = 'SELECT a.uuid, b.sub_option_id FROM f_t_daren_score_2 a LEFT JOIN d_shangju_tiku_02 b ON a.testcase_id ' \
|
|
|
+ '= b.testcase_id WHERE a.sub_question_id = b.sub_question_id AND (a.score = b.score OR a.score = ' \
|
|
|
+ 'b.sub_option_id) AND a.uuid = %s AND a.sub_question_id = 286 and a.status = b.status = 1 '
|
|
|
|
|
|
def __init__(self, path=None):
|
|
|
self.shangju_db = MysqlDB('shangju')
|
|
@@ -265,24 +239,27 @@ class Mvp:
|
|
|
nld_1 = '无年龄'
|
|
|
|
|
|
testcastids = list(map(int, str(testcaseid).split(',')))
|
|
|
- gt_75 = [x for x in testcastids if x > 75]
|
|
|
- if city is None and len(gt_75) > 0:
|
|
|
- # 从答题结果中获取城市信息
|
|
|
- citys = self.marketing_db.select(self.sql_16, [uuid])
|
|
|
- if len(citys) > 0:
|
|
|
- city = citys[0][1]
|
|
|
- else:
|
|
|
- city = '无城市'
|
|
|
- # 根据用户子选项id集合,获取用户的人群分类
|
|
|
crowd = []
|
|
|
- if len(gt_75) > 0:
|
|
|
- # 特定的测试人群分类从答题结果中获取
|
|
|
- sub_option_ids = self.marketing_db.select(self.sql_17, [uuid])
|
|
|
- for option in sub_option_ids:
|
|
|
- crowd.append(self.crowd_info[option[1]])
|
|
|
+ if len(testcastids) > 0:
|
|
|
+ gt_75 = [x for x in testcastids if x in [75, 76, 77, 78]]
|
|
|
+ if city is None and len(gt_75) > 0:
|
|
|
+ # 从答题结果中获取城市信息
|
|
|
+ citys = self.marketing_db.select(self.sql_16, [uuid])
|
|
|
+ if len(citys) > 0:
|
|
|
+ city = citys[0][1]
|
|
|
+ else:
|
|
|
+ city = '无城市'
|
|
|
+ # 根据用户子选项id集合,获取用户的人群分类
|
|
|
+ if len(gt_75) > 0:
|
|
|
+ # 特定的测试人群分类从答题结果中获取
|
|
|
+ sub_option_ids = self.marketing_db.select(self.sql_17, [uuid])
|
|
|
+ for option in sub_option_ids:
|
|
|
+ crowd.append(self.crowd_info[option[1]])
|
|
|
else:
|
|
|
if str(sub_option_ids).strip():
|
|
|
crowd.extend(self.get_people_uuid_by_sub_option_ids(sub_option_ids))
|
|
|
+ if city is None:
|
|
|
+ city = '无城市'
|
|
|
people_info = PeopleInfo(uuid, city, nld_1, sex, crowd)
|
|
|
people_infos.append(people_info)
|
|
|
return people_infos
|