Ejemplo n.º 1
0
 def update_user_data(badge, b):
     data = badge.get('data', [])
     # There might be a max batch size? We'll find out.
     to_put = []
     for item in data:
         email = item['email']
         value = int(item['value'])  # JSON might turn it into a float.
         uid = '%s:%s' % (b.badge_name, email)
         d = UserData.get_by_id(id=uid)
         if d and not d.visible:
             continue
         d = UserData(badge_name=b.badge_name,
                      email=email,
                      value=value,
                      visible=True,
                      id=uid)
         to_put.append(d)
     ndb.put_multi(to_put)