Browse Source

mvp: 模块分数计算逻辑调整

Signed-off-by: binren <zhangbr@elab-plus.com>
binren 5 years ago
parent
commit
2f6949c3a8
2 changed files with 7 additions and 7 deletions
  1. 5 5
      mvp.py
  2. 2 2
      mysql_db.py

+ 5 - 5
mvp.py

@@ -276,12 +276,12 @@ class Mvp:
             crowd_info_id,
             gender,
             standard_value,
-            STATUS,
+            status,
             creator,
             created
         )
         VALUES
-            (%s, %s, %s, 1, %s, now())
+            (%s, %s, %s, 1, 'binren', now())
     '''
 
     """
@@ -493,9 +493,9 @@ class Mvp:
                     crowd_info_id = self.get_crowd_info_id([city, age, crowd])
                     if crowd_info_id and (boy + girl) > 0:
                         boy_rate = boy / (boy + girl)
-                        insert_data.append([crowd_info_id, 1, boy_rate, 'binren'])
+                        insert_data.append([crowd_info_id, 1, boy_rate])
                         girl_rate = girl / (boy + girl)
-                        insert_data.append([crowd_info_id, 0, girl_rate, 'binren'])
+                        insert_data.append([crowd_info_id, 0, girl_rate])
         if len(insert_data) > 0:
             self.linshi_db.truncate('mvp_crowd_info_gender_rate')
             self.linshi_db.add_some(self.sql_22, insert_data)
@@ -604,7 +604,7 @@ class Mvp:
             for value in values:
                 behavioral_name = value[0]
                 weight = float(value[2])
-                standard_score = [x[4] for x in scores if x[2] == behavioral_name]
+                standard_score = [x[4] for x in scores if x[3] == behavioral_name]
                 if len(standard_score) > 0:
                     score += standard_score[0] * weight
             result.append([city, age, crowd, module_name, score])

+ 2 - 2
mysql_db.py

@@ -52,8 +52,8 @@ class MysqlDB:
         try:
             self.cursor.executemany(sql, data)
             self.con.commit()
-        except:
-            print('数据插入异常...')
+        except Exception as e:
+            print('数据插入异常...{}'.format(e))
             self.con.rollback()
 
     def add_one(self, sql, data):