|
@@ -104,10 +104,28 @@ class Mvp:
|
|
|
sql_5 = 'select testcase_id, COUNT(uuid) from f_t_daren_score_2 where uuid in %s group by testcase_id '
|
|
|
|
|
|
# 根据父选项获取子选项id列表
|
|
|
- sql_6 = 'SELECT c.id, c.sub_question_id, c.content FROM bq_sub_option c WHERE c.father_id in (SELECT a.id FROM ' \
|
|
|
- 'bq_option a ' \
|
|
|
- 'LEFT JOIN bq_question b ON a.question_id = b.id WHERE a.serial_number = %s AND b.serial_number = %s ' \
|
|
|
- 'and a.status = 1 and b.status = 1) and c.status = 1 '
|
|
|
+ sql_6 = '''
|
|
|
+ SELECT
|
|
|
+ c.id,
|
|
|
+ c.sub_question_id,
|
|
|
+ c.content
|
|
|
+ FROM
|
|
|
+ bq_sub_option c
|
|
|
+ WHERE
|
|
|
+ c.father_id IN (
|
|
|
+ SELECT
|
|
|
+ a.id
|
|
|
+ FROM
|
|
|
+ bq_option a
|
|
|
+ LEFT JOIN bq_question b ON a.question_id = b.id
|
|
|
+ WHERE
|
|
|
+ a.serial_number = % s
|
|
|
+ AND b.serial_number = % s
|
|
|
+ AND a. STATUS = 1
|
|
|
+ AND b. STATUS = 1
|
|
|
+ )
|
|
|
+ AND c. STATUS = 1
|
|
|
+ '''
|
|
|
|
|
|
# 根据子题id获取包含子题id的测试
|
|
|
sql_7 = 'select id from bq_testcase where status = 1 and FIND_IN_SET(%s, question_ids)'
|
|
@@ -188,7 +206,7 @@ class Mvp:
|
|
|
)
|
|
|
AND a.uuid = %s
|
|
|
AND b.father_id = 249
|
|
|
- AND a. STATUS = b. STATUS = 1
|
|
|
+ AND a.STATUS = b. STATUS = 1
|
|
|
'''
|
|
|
|
|
|
# 答题人人群分类信息
|
|
@@ -207,9 +225,49 @@ class Mvp:
|
|
|
)
|
|
|
AND a.uuid = %s
|
|
|
AND b.father_id = 236
|
|
|
- AND a. STATUS = b. STATUS = 1
|
|
|
+ AND a.STATUS = b.STATUS = 1
|
|
|
'''
|
|
|
|
|
|
+ """
|
|
|
+ 数据debug SQL
|
|
|
+ 1:
|
|
|
+ SELECT
|
|
|
+ c.id,
|
|
|
+ c.sub_question_id,
|
|
|
+ c.content
|
|
|
+ FROM
|
|
|
+ bq_sub_option c
|
|
|
+ WHERE
|
|
|
+ c.father_id IN (
|
|
|
+ SELECT
|
|
|
+ a.id
|
|
|
+ FROM
|
|
|
+ bq_option a
|
|
|
+ LEFT JOIN bq_question b ON a.question_id = b.id
|
|
|
+ WHERE
|
|
|
+ a.serial_number ='FA001'
|
|
|
+ AND b.serial_number = 'F00245'
|
|
|
+ AND a. STATUS = 1
|
|
|
+ AND b. STATUS = 1
|
|
|
+ )
|
|
|
+ AND c.STATUS = 1
|
|
|
+ 2:
|
|
|
+ select id from bq_testcase where status = 1 and FIND_IN_SET(%s, question_ids)
|
|
|
+ 3:
|
|
|
+ SELECT
|
|
|
+ count(1)
|
|
|
+ FROM
|
|
|
+ f_t_daren_score_2 a
|
|
|
+ LEFT JOIN d_shangju_tiku_02 b ON a.sub_question_id = b.sub_question_id
|
|
|
+ AND (
|
|
|
+ a.score = b.score
|
|
|
+ OR a.score = b.sub_option_id
|
|
|
+ )
|
|
|
+ AND a.testcase_id = b.testcase_id
|
|
|
+ WHERE
|
|
|
+ b.sub_option_id IN (1964,1965,1966,1967,1968,1969,1970,1971,1972)
|
|
|
+ """
|
|
|
+
|
|
|
def __init__(self, path=None):
|
|
|
self.shangju_db = MysqlDB('shangju')
|
|
|
self.marketing_db = MysqlDB('bi_report')
|
|
@@ -293,7 +351,7 @@ class Mvp:
|
|
|
if testcaseid:
|
|
|
testcastids = list(map(int, str(testcaseid).split(',')))
|
|
|
if len(testcastids) > 0:
|
|
|
- gt_75 = [x for x in testcastids if x in [75, 76, 77, 78]]
|
|
|
+ gt_75 = [x for x in testcastids if x > 74]
|
|
|
if city is None and len(gt_75) > 0:
|
|
|
# 从答题结果中获取城市信息
|
|
|
citys = self.marketing_db.select(self.sql_16, [uuid])
|
|
@@ -302,8 +360,6 @@ class Mvp:
|
|
|
city_name = info[1]
|
|
|
if city_name in ['一线', '二线', '其他']:
|
|
|
city = city_name
|
|
|
- else:
|
|
|
- city = '二线'
|
|
|
# 根据用户子选项id集合,获取用户的人群分类
|
|
|
if len(gt_75) > 0:
|
|
|
# 特定的测试人群分类从答题结果中获取
|