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