本文整理汇总了Python中models.Activity.get_private_activity方法的典型用法代码示例。如果您正苦于以下问题:Python Activity.get_private_activity方法的具体用法?Python Activity.get_private_activity怎么用?Python Activity.get_private_activity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Activity
的用法示例。
在下文中一共展示了Activity.get_private_activity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: consecutive_seens
# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import get_private_activity [as 别名]
def consecutive_seens(player, timestamp):
"""
Return the count of consecutive seens for a player, until timestamp
"""
activities = Activity.get_private_activity(player).filter(action='seen').order_by('-timestamp')[0:100]
today = timestamp.date()
for i, activity in enumerate(activities):
date = activity.timestamp.date()
if date != today + timedelta(days=-i):
return i
return len(activities)
示例2: consecutive_days_seen
# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import get_private_activity [as 别名]
def consecutive_days_seen(player, timestamp):
"""
Return the count of consecutive seens for a player, until timestamp
"""
# The maximum number of seens in the last 15 days is 24 * 15 ( we have a new 'seen' activity each hour ).
maximum_times_seen = 15 * 24
activities = Activity.get_private_activity(player).filter(action='seen').order_by('-timestamp')[0:maximum_times_seen]
last_day = timestamp.date()
consecutive_days = 1
for i, activity in enumerate(activities):
date = activity.timestamp.date()
if date == last_day + timedelta(days=-1):
last_day = date
consecutive_days = consecutive_days + 1
elif last_day - date >= timedelta(days=2):
break
return consecutive_days