本文整理汇总了Python中models.Score.maybe_update_score方法的典型用法代码示例。如果您正苦于以下问题:Python Score.maybe_update_score方法的具体用法?Python Score.maybe_update_score怎么用?Python Score.maybe_update_score使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Score
的用法示例。
在下文中一共展示了Score.maybe_update_score方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: player_data
# 需要导入模块: from models import Score [as 别名]
# 或者: from models.Score import maybe_update_score [as 别名]
def player_data():
if not request.json or 'player' not in request.json:
print(request, request.json)
abort(400)
db = get_db()
player_data = request.json['player']
friends = player_data['friends']
puzzle_data = player_data['puzzle_data']
del player_data['friends']
del player_data['puzzle_data']
player = Player.get_or_create(player_data)
db.session.query(Player).filter(
Player.social_id == player.social_id).update(player_data)
for friend_social_id in friends:
friend = Player.get_or_create({"social_id": friend_social_id})
player.add_friendship(friend)
for index, puzzle_id in enumerate(puzzle_data['puzzles']):
Score.maybe_update_score({
'player_social_id': player.social_id,
'puzzle_id': puzzle_id,
'score': puzzle_data['scores'][index],
'stars': puzzle_data['stars'][index]})
db.session.commit()
return jsonify(
_assemble_response(player))