本文整理匯總了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])