本文整理汇总了Python中models.Activity.get_player_activity方法的典型用法代码示例。如果您正苦于以下问题:Python Activity.get_player_activity方法的具体用法?Python Activity.get_player_activity怎么用?Python Activity.get_player_activity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Activity
的用法示例。
在下文中一共展示了Activity.get_player_activity方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: challenge_count
# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import get_player_activity [as 别名]
def challenge_count(player, days=None):
"""
Return the count of challenges played by player in the last x _days_.
All challenges if days == None
"""
if not days:
return Activity.get_player_activity(player).filter(action__contains='chall').count()
start = datetime.now() - timedelta(days=days)
return Activity.get_player_activity(player).filter(
action__contains='chall', timestamp__gte=start).count()
示例2: refused_challenges
# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import get_player_activity [as 别名]
def refused_challenges(player):
"""
Return the count of refused challenges in the last week
"""
start = datetime.now() + timedelta(days=-7)
return Activity.get_player_activity(player).filter(action__contains='chall-refused', timestamp__gte=start,
user_from=player).count()
示例3: wrong_first_qotd
# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import get_player_activity [as 别名]
def wrong_first_qotd(player):
"""
Check if the first answer to qotd was a wrong answer.
"""
activities = Activity.get_player_activity(player).filter(action__contains='qotd')
if not activities.count() == 1:
return False
if activities[0].action == 'qotd-wrong':
return True
return False
示例4: challenges_played_today
# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import get_player_activity [as 别名]
def challenges_played_today(player):
"""
Return the count of challenges played today
"""
today = datetime.now().date()
activities = Activity.get_player_activity(player).filter(action__contains='chall', timestamp__gte=today)
result = 0
for a in activities:
if not 'refused' in a.action:
result += 1
return result
示例5: consecutive_qotd_correct
# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import get_player_activity [as 别名]
def consecutive_qotd_correct(player):
"""
Return the count of correct qotd in a row
"""
activities = Activity.get_player_activity(player).filter(action__contains = 'qotd').order_by('-timestamp')[:12]
result = 0
for i in activities:
if 'correct' in i.action:
result +=1
else:
return result
return result
示例6: consecutive_chall_won
# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import get_player_activity [as 别名]
def consecutive_chall_won(player):
"""
Return the count of won challenges in a row
Maximum: 10 (last ten)
"""
activities = Activity.get_player_activity(player).filter(action__contains='chall').order_by('-timestamp')[:10]
result = 0
for i in activities:
if 'won' in i.action and i.user_from.id == player.id:
result += 1
else:
return result
return result
示例7: challenge_count
# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import get_player_activity [as 别名]
def challenge_count(player):
"""
Return the count of challenges played by player.
"""
return Activity.get_player_activity(player).filter(action__contains='chall').count()