Browse Source

mvp: 添加测试接口

Signed-off-by: binren <zhangbr@elab-plus.com>
binren 5 years ago
parent
commit
69f20c732f
3 changed files with 36 additions and 2 deletions
  1. 1 1
      excel_util.py
  2. 1 1
      flask_app.py
  3. 34 0
      mvp.py

+ 1 - 1
excel_util.py

@@ -98,7 +98,7 @@ class ExcelUtil:
         result = {}
         datas.sort(key=lambda obj: obj[0])
         for tag_type, sub_datas in groupby(datas, key=lambda obj: obj[0]):
-            if tag_type not in no_need_module:
+            if tag_type == '用户画像-审美偏好':
                 sub_list = [x for x in sub_datas]
                 sub_list.sort(key=lambda obj: obj[1])
                 sub_result = {}

+ 1 - 1
flask_app.py

@@ -17,7 +17,7 @@ def score():
     crowd = request.args.get('crowd', default=None, type=str)
     print(city, age, crowd)
     mvp = Mvp()
-    scores = mvp.query_behavioral_info(city, age, crowd)
+    scores = mvp.fz_fm(city, age, crowd)
     mvp.close()
     return json.dumps(scores, ensure_ascii=False)
 

+ 34 - 0
mvp.py

@@ -403,6 +403,10 @@ class Mvp:
         print('update finished!!!')
         return scores_behavioral
 
+    def fz_fm(self, city=None, age=None, crowd=None):
+        scores_behavioral = self.city_age_crowd_1(city, age, crowd)
+        return scores_behavioral
+
     def people_info(self):
         """
             答题人个人信息获取
@@ -745,6 +749,36 @@ class Mvp:
         return {'behavior_score': result, 'module_score': module_scores}
         # return {'score': result, 'data': data_list}
 
+    def city_age_crowd_1(self, city=None, age=None, crowd=None):
+        data_start = []
+        result = []
+        module_scores = []
+        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)
+            people_uuids = self.people_filter(city, age, crowd)
+            behavior_data = None
+            if len(people_uuids) > 0:
+                print('{}-{}-{}'.format(city, age, crowd))
+                datas = self.behavior_tag_init(city, age, people_uuids)
+                data_start.append(datas)
+                all_data, behavior_data_1 = self.calculation_standard_score(datas, city, age, crowd)
+                result.append(all_data)
+                behavior_data = behavior_data_1
+            if behavior_data:
+                module_scores.extend(self.module_score(crowd, city, age, behavior_data))
+        # data_list = []
+        # for e in data_start:
+        #     for key in e.keys():
+        #         values = e[key]
+        #         for sub_e in values:
+        #             ele = [key]
+        #             ele.extend(sub_e)
+        #             data_list.append(ele)
+        #     pass
+        return datas
+        # return {'score': result, 'data': data_list}
+
     def scores(self):
         behavior_score = []
         module_scores = []