Browse Source

flask_app;remove api people

Signed-off-by: binren <zhangbr@elab-plus.com>
binren 5 years ago
parent
commit
3383f65fa2
2 changed files with 24 additions and 31 deletions
  1. 0 8
      flask_app.py
  2. 24 23
      mvp.py

+ 0 - 8
flask_app.py

@@ -97,14 +97,6 @@ def update_data():
     return '!!!score update finished!!!'
 
 
-@app.route('/people', methods=['GET', 'POST'])
-def people_info():
-    mvp = Mvp()
-    result = mvp.people_info_1
-    mvp.close()
-    return json.dumps(result, ensure_ascii=False)
-
-
 if __name__ == '__main__':
     app.run(
         host='0.0.0.0',

+ 24 - 23
mvp.py

@@ -238,28 +238,27 @@ class Mvp:
                 pass
 
             crowd = []
-            if str(testcaseid).find(',') != -1:
-                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]
-                        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)
+            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]
                     else:
-                        if str(sub_option_ids_1).find(',') != -1:
-                            crowd.extend(self.get_people_uuid_by_sub_option_ids(sub_option_ids_1))
+                        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 city is None:
                 city = '无城市'
             people_info = PeopleInfo(uuid, city, nld, sex, crowd)
@@ -467,6 +466,8 @@ class Mvp:
         result = []
         module_scores = []
         self.people_info_1 = self.people_info()
+        for people in self.people_info_1:
+            print(people.uuid, people.age, people.crowd, people.city, people.sex)
         if city is not None and age is not None and crowd is not None:
             print('获取指定城市,年龄段,人群类型的数据...')
             # people_uuids = self.get_people_uuid_by_type(crowd)
@@ -656,9 +657,9 @@ class Mvp:
                         sub_option_id, sub_question_id, content = qr[0], qr[1], qr[2]
                         sub_option_ids.append(int(sub_option_id))
             infos[key] = sub_option_ids
-        print(infos)
         return infos
 
 
 if __name__ == '__main__':
-    print('{}哈{}ha%s'.format('1', '2'))
+    mvp = Mvp()
+    mvp.people_info()