当前位置: 首页>>代码示例>>Python>>正文


Python Activity.get_private_activity方法代码示例

本文整理汇总了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)
开发者ID:anaion,项目名称:wouso,代码行数:14,代码来源:achievements.py

示例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
开发者ID:gabrielivascu,项目名称:wouso,代码行数:25,代码来源:achievements.py


注:本文中的models.Activity.get_private_activity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。