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 = {}
评论列表
文章目录