builders.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:betterself 作者: jeffshek 项目源码 文件源码
def __init__(self, user, periods_back=30):
        self.user = user
        self.hour_series = range(0, 24)

        historical_data_points_quantity = periods_back

        end_date = timezone.now()

        # use pandas to generate a nifty index of timestamps, use timezone to remove warning signals
        self.date_series = pd.date_range(end=end_date, freq='D', periods=historical_data_points_quantity)

        # build a series that shows the impact of what supplements/events have on sleep
        self.sleep_impact_series = pd.Series(0, index=self.date_series)
        self.productivity_impact_series = pd.Series(0, index=self.date_series)

        self.sleep_series = self._get_random_sleep_series(self.date_series)

        # Create a cache here because creating many events is very slow on Production ...
        # so create a cache of commonly used Django objects and then create a bunch of events that
        # need this foreign key, so we can use bulk_create
        self.user_activities = {}
        self.supplements = {}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号