本文整理汇总了Python中users.Users.query方法的典型用法代码示例。如果您正苦于以下问题:Python Users.query方法的具体用法?Python Users.query怎么用?Python Users.query使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类users.Users
的用法示例。
在下文中一共展示了Users.query方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: stats
# 需要导入模块: from users import Users [as 别名]
# 或者: from users.Users import query [as 别名]
def stats(self):
data = memcache.get('stats')
if data is not None:
return data
else:
self.users = Users()
users = [0, 0, 0]
points = [0, 0, 0]
for user in Users.query().fetch():
if user.faction:
users[user.faction-1] += 1
points[user.faction-1] += user.get_points_sum(user.key.id())
faUsers = []
for usr in users:
faUsers.append(FactionUsers_m(users=usr))
stats = []
for usr in points:
stats.append(Stats_m(points=usr))
logging.info("%s", users)
fa_stats = FactionStats_m(users=faUsers, stats=stats)
memcache.add(key="stats", value=fa_stats, time=160)
return fa_stats
示例2: generateLeaderboard
# 需要导入模块: from users import Users [as 别名]
# 或者: from users.Users import query [as 别名]
def generateLeaderboard(self):
leaderboard = []
leaderboard_a = []
cntr = 0
for user in Users.query().fetch():
u = user.get(user.key.id())
p = user.get_points_sum(user.key.id())
leaderboard.append(Leaderboard_entry_m(
user=u,
points=p
))
if p > 0:
cntr += 1
logging.info("total playing count: " + str(cntr))
leaderboard.sort(key=lambda x: x.points, reverse=True)
lb_m = Leaderboard_m(leaderboard=leaderboard[:20])
if Leaderboard().query().get():
lb = Leaderboard().query().get()
lb.leaderboard = lb_m
lb.put()
else:
lb = Leaderboard(leaderboard=lb_m)
lb.put()
# lb_short = Leaderboard_m(leaderboard=lb_m.leaderboard[:20])
memcache.add(key="leaderboard", value=lb_m, time=500)
示例3: leaderboard
# 需要导入模块: from users import Users [as 别名]
# 或者: from users.Users import query [as 别名]
def leaderboard(self, limit):
leaderboard = []
for user in Users.query().fetch():
leaderboard.append(Leaderboard_entry_m(
user=user.get(user.key.id()),
points=user.get_points_sum(user.key.id())
))
leaderboard.sort(key=lambda x: x.points, reverse=True)
return Leaderboard_m(leaderboard=leaderboard[:limit])