Browse Source

修复批量添加不上的问题

pzb 6 years ago
parent
commit
f8c45597c9
1 changed files with 15 additions and 1 deletions
  1. 15 1
      Controller/UserBrandController.py

+ 15 - 1
Controller/UserBrandController.py

@@ -146,8 +146,21 @@ class MyserviceDynamodb(object):
         dynamodb = self.session.resource('dynamodb')
         table = dynamodb.Table(table_name)
         with table.batch_writer() as batch:
+
             for i in data_list:
                 data = json.loads(i.decode('utf-8'))
+                # print (json.loads(i))
+                # data = i
+                if data['city'] == '':
+                    data['city'] = '无'
+                if data['area'] == '':
+                    data['area'] = '无'
+                if data['street'] == '':
+                    data['street'] = '无'
+                if data['longitude'] == '':
+                    data['longitude'] = '无'
+                if data['latitude'] == '':
+                    data['latitude'] = '无'
                 batch.put_item(
                     Item={
                         'userID': data['userID'],
@@ -445,6 +458,7 @@ class UserBrandInfo(View):
             longitude='无'
         if latitude is None:
             latitude='无'
+
         param_area = CommonService.get_param_flag(data=[country,province,city])
         must_fill_in = CommonService.get_param_flag(data=[appId,deviceSupplier,deviceModel,osType,osVersion])
         if must_fill_in is False:
@@ -516,7 +530,7 @@ class UserBrandInfo(View):
             redisObj.rpush(name=logKey, val=add_user_brand_all_data)
             print (redisObj.llen(name=logKey))
             # 判断redis列表长度
-            if redisObj.llen(name=logKey) > 10:
+            if redisObj.llen(name=logKey) > 1:
                 data_list = redisObj.lrange(logKey, 0, -1)
                 redisObj.del_data(key=logKey)
                 # 添加user_brand_all表信息