Browse Source

mvp: 年龄处理逻辑调整

Signed-off-by: binren <zhangbr@elab-plus.com>
binren 5 years ago
parent
commit
87b7a09dd8
2 changed files with 32 additions and 3 deletions
  1. 22 0
      entity.py
  2. 10 3
      mvp.py

+ 22 - 0
entity.py

@@ -3,6 +3,19 @@ class PeopleInfo:
     答题人个人信息
    """
 
+    age_dict = {
+        '00-04年生': '95后',
+        '05-09年生': '05后',
+        '50-59年生': '50后',
+        '60-69年生': '60后',
+        '70-74年生': '70后',
+        '75-79年生': '75后',
+        '80-84年生': '80后',
+        '85-89年生': '85后',
+        '90-94年生': '85后',
+        '95-99年生': '95后'
+    }
+
     def __init__(self, uuid, city=None, age=None, sex=None, crowd=None):
         if crowd is None:
             crowd = []
@@ -13,6 +26,15 @@ class PeopleInfo:
             self.city = '上海周边'
         else:
             self.city = city
+        age_1 = self.age_dict.get(age)
+        if age_1:
+            self.age = age_1
+        else:
+            age = ''
         self.age = age
         self.sex = sex
         self.crowd = crowd
+
+
+if __name__ == '__main__':
+    print('1'.split(','))

+ 10 - 3
mvp.py

@@ -250,11 +250,18 @@ class Mvp:
             city = people[1]
             if city:
                 city = str(city).split('市')[0] + '市'
-            nld = people[2]
+            nld = list(str(people[2]).split(','))
+            nld_1 = None
+            if len(nld) > 0:
+                nld_1 = nld[0]
+            else:
+                nld_1 = ''
             sex = people[3]
             sub_option_ids = people[4]
             testcaseid = people[5]
-            if city is None and testcaseid > 75:
+            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:
@@ -268,7 +275,7 @@ class Mvp:
                     crowd.append(self.crowd_info[option[1]])
             else:
                 crowd.extend(self.get_people_uuid_by_sub_option_ids(sub_option_ids))
-            people_info = PeopleInfo(uuid, city, nld, sex, crowd)
+            people_info = PeopleInfo(uuid, city, nld_1, sex, crowd)
             people_infos.append(people_info)
         return people_infos