瀏覽代碼

mvp: 城市 年龄

Signed-off-by: binren <zhangbr@elab-plus.com>
binren 5 年之前
父節點
當前提交
9980670787
共有 2 個文件被更改,包括 32 次插入24 次删除
  1. 4 2
      entity.py
  2. 28 22
      mvp.py

+ 4 - 2
entity.py

@@ -28,10 +28,12 @@ class PeopleInfo:
         if age_1:
             self.age = age_1
         else:
-            self.age = '无年龄'
+            self.age = '95后'
         self.sex = sex
         self.crowd = crowd
 
 
 if __name__ == '__main__':
-    print(len(''))
+    ss = {'A': 'b', 'B': 's'}
+    for key in ss.keys():
+        print(key)

+ 28 - 22
mvp.py

@@ -238,29 +238,35 @@ class Mvp:
                 pass
 
             crowd = []
-            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]]
-                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]
+            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]]
+                    if city is None and 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
+                        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_type = self.crowd_info_1.get(option[1])
+                            if crowd_type:
+                                crowd.append(crowd_type)
+                            else:
+                                crowd.append('A')
                     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_type = self.crowd_info_1.get(option[1])
-                        if crowd_type:
-                            crowd.append(crowd_type)
-                else:
-                    if str(sub_option_ids_1).find(',') != -1:
-                        crowd.extend(self.get_people_uuid_by_sub_option_ids(sub_option_ids_1))
+                        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])
@@ -520,7 +526,7 @@ class Mvp:
         result = {}
         self.group_type_count = self.marketing_db.select(self.sql_5, [people_uuids])
         # 表名
-        for key in self.tag_data:
+        for key in self.tag_data.keys():
             values = self.tag_data[key]
             result_sub = {}
             # 标签