本文整理汇总了Python中models.Score.query_current_user方法的典型用法代码示例。如果您正苦于以下问题:Python Score.query_current_user方法的具体用法?Python Score.query_current_user怎么用?Python Score.query_current_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Score
的用法示例。
在下文中一共展示了Score.query_current_user方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: scores_list
# 需要导入模块: from models import Score [as 别名]
# 或者: from models.Score import query_current_user [as 别名]
def scores_list(self, request):
"""Exposes an API endpoint to query for scores for the current user.
Args:
request: An instance of ScoresListRequest parsed from the API
request.
Returns:
An instance of ScoresListResponse containing the scores for the
current user returned in the query. If the API request specifies an
order of WHEN (the default), the results are ordered by time from
most recent to least recent. If the API request specifies an order
of TEXT, the results are ordered by the string value of the scores.
"""
query = Score.query_current_user()
if request.order == ScoresListRequest.Order.TEXT:
query = query.order(Score.outcome)
elif request.order == ScoresListRequest.Order.WHEN:
query = query.order(-Score.played)
items = [entity.to_message() for entity in query.fetch(request.limit)]
return ScoresListResponse(items=items)