예제 #1
0
 def get_last_open_session(self, dtime, uid):
     dt = day_serialize(dtime)
     try:
         return self.data_per_days[dt][uid][-1]
     except (KeyError, IndexError) as no_sessions:
         # session may break at midnight as we're looking on daily basis
         prev_dt = day_serialize(dtime - datetime.timedelta(days=1))
         try:
             return self.data_per_days[prev_dt][uid][-1]
         except (KeyError, IndexError) as no_prev_day_sessions:
             # we assume we have no sessions
             # with more than a 24-hour duration
             return
예제 #2
0
 def get_last_open_session(self, dtime, uid):
     dt = day_serialize(dtime)
     try:
         return self.data_per_days[dt][uid][-1]
     except (KeyError, IndexError) as no_sessions:
         # session may break at midnight as we're looking on daily basis
         prev_dt = day_serialize(dtime - datetime.timedelta(days=1))
         try:
             return self.data_per_days[prev_dt][uid][-1]
         except (KeyError, IndexError) as no_prev_day_sessions:
             # we assume we have no sessions
             # with more than a 24-hour duration
             return
예제 #3
0
    def create_broken_session(self, dtime, uid):
        dt = day_serialize(dtime)

        session = Session(start=dtime,
                          mode=self._users2modes.get(uid, None),
                          is_broken=True)

        self.data_per_days[dt].setdefault(uid, []).append(session)

        return session
예제 #4
0
    def create_broken_session(self, dtime, uid):
        dt = day_serialize(dtime)

        session = Session(
            start=dtime, mode=self._users2modes.get(uid, None),
            is_broken=True
        )

        self.data_per_days[dt].setdefault(uid, []).append(session)

        return session
예제 #5
0
 def process_unspecified(self, event):
     dte = day_serialize(event.event_time.dtime.date())
     if event.event_time.is_accurate:
         self.dates[dte]['users'].add(event.user_info.uid)
         self.dates[dte]['events'] += 1
예제 #6
0
 def get_session_history(self, dtime, uid):
     return self.data_per_days[day_serialize(dtime)].setdefault(uid, [])
예제 #7
0
 def get_session_history(self, dtime, uid):
     return self.data_per_days[day_serialize(dtime)].setdefault(uid, [])
예제 #8
0
 def process_unspecified(self, event):
     dte = day_serialize(event.event_time.dtime.date())
     if event.event_time.is_accurate:
         self.dates[dte]["users"].add(event.user_info.uid)
         self.dates[dte]["events"] += 1