def process_event(event): """ Process event by sending events to the realtime event feed, storing events in postgres and updating the buckets in redis. Args: event: a dictionary containing event information Return: None """ # send events to channels group to be sent to the events feed Group("events").send({"text": event}) Event.objects.get_or_create( user_name=event["user"], date=pytz.utc.localize(datetime.utcfromtimestamp(event["date"] / 1000)), event_type=event["eventType"], event_info=event.get("eventInfo", {}), ) # update statistics DataStoreService().update_buckets(event)
def daily_goal_complete_event(self): print 'DailyGoalCompletedEvent' # update statistics DataStoreService().update_buckets(self.event)
def get_monthly_history(self, user): """ Retrieve daily buckets for this month. """ buckets = DataStoreService().get_buckets_current_month(user) return self.generate_bucket_lists(buckets)
def work_session_completed_event(self): print 'WorkSessionCompletedEvent' # update statistics DataStoreService().update_buckets(self.event)
def get_daily_history(self, user): """ Retrieve hourly buckets for today. """ buckets = DataStoreService().get_buckets_current_day(user) return self.convert_buckets_to_dict(buckets)