Procházet zdrojové kódy

mvp: city

Signed-off-by: binren <zhangbr@elab-plus.com>
binren před 5 roky
rodič
revize
54a79257e6
1 změnil soubory, kde provedl 27 přidání a 23 odebrání
  1. 27 23
      mvp.py

+ 27 - 23
mvp.py

@@ -65,7 +65,7 @@ class Mvp:
         '1818': 'F',
         '1819': 'G'
     }
-    base_insert_sql = 'insert into {}(crowd_info_id, {}, standard_value, status) values(%s, %s, %s, '\
+    base_insert_sql = 'insert into {}(crowd_info_id, {}, standard_value, status) values(%s, %s, %s, ' \
                       '1) '
 
     def get_table_name(self, name):
@@ -192,21 +192,28 @@ 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 b.father_id = 249
-        AND a.STATUS = b. STATUS = 1
+            SELECT
+                a.uuid,
+                CASE b.sub_option_content
+            WHEN '一线' THEN
+                '上海市'
+            WHEN '二线' THEN
+                '上海周边'
+            WHEN '其他' THEN
+                '其他'
+            END AS city
+            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 = 'ae9db26b-3606-497c-83c5-56341d487a91'
+            AND b.father_id = 249
+            AND a. STATUS = b. STATUS = 1
     '''
 
     # 答题人人群分类信息
@@ -352,14 +359,11 @@ class Mvp:
                 testcastids = list(map(int, str(testcaseid).split(',')))
                 if len(testcastids) > 0:
                     gt_75 = [x for x in testcastids if x > 74]
-                    if city is None and len(gt_75) > 0:
+                    if len(gt_75) > 0:
                         # 从答题结果中获取城市信息
                         citys = self.marketing_db.select(self.sql_16, [uuid])
                         if len(citys) > 0:
-                            for info in citys:
-                                city_name = info[1]
-                                if city_name in ['一线', '二线', '其他']:
-                                    city = city_name
+                            city = citys[0][1]
                     # 根据用户子选项id集合,获取用户的人群分类
                     if len(gt_75) > 0:
                         # 特定的测试人群分类从答题结果中获取
@@ -374,7 +378,7 @@ class Mvp:
                         if sub_option_ids_1 is not None:
                             crowd.extend(self.get_people_uuid_by_sub_option_ids(sub_option_ids_1))
             if city is None:
-                city = '一线'
+                city = '上海市'
             people_info = PeopleInfo(uuid, city, nld, sex, crowd)
             people_infos.append(people_info)
             # people_infos.append([uuid, city, nld, sex, crowd])
@@ -784,4 +788,4 @@ class Mvp:
 
 if __name__ == '__main__':
     mvp = Mvp()
-    mvp.people_info()
+    mvp.people_info()