zeeguu/core/model/word_knowledge/word_interaction_history.py
def add_event(self, event_type, timestamp, timedelta = TIMEDELTA):
        """
            add a new event, no comparison or duplication check involved, use
            only if an original event is certain
            use for live implementation where time goes in one direction =)
        :param event_type:
        :param timestamp:
        :return:
        """

        # json can't serialize timestamps, so we simply
        seconds_since_epoch = int(timestamp.strftime("%s"))

        self.interaction_history.insert(0, WordInteractionEvent(event_type, seconds_since_epoch))
        self.interaction_history = self.interaction_history[0:MAX_EVENT_HISTORY_LENGTH]

        # change event if an event was already recorded within the timedelta
        if self.interaction_history[-1].seconds_since_epoch + timedelta >= seconds_since_epoch:
            self.interaction_history[-1].seconds_since_epoch = seconds_since_epoch
            if event_type == WIH_READ_CLICKED:
                self.interaction_history[-1].event_type = event_type

        # append if less than 50 events recorded
        elif len(self.interaction_history) < MAX_EVENT_HISTORY_LENGTH:
            self.interaction_history.append(WordInteractionEvent(event_type, seconds_since_epoch))

        # append new event and pop oldest event
        else:
            self.interaction_history.append(WordInteractionEvent(event_type, seconds_since_epoch))
            self.interaction_history.pop(0)

            add a new event, no comparison or duplication check involved, use
            only if an original event is certain
            use for live implementation where time goes in one direction =)
        :param event_type:
        :param timestamp:
        :return:
        
add a new event, no comparison or duplication check involved, use
only if an original event is certain
use for live implementation where time goes in one direction =)
add a new event no comparison or duplication check involved use only if an original event is certain use for live implementation where time goes in one direction = )
def add_event(self, event_type, timestamp, timedelta = TIMEDELTA):
        seconds_since_epoch = int(timestamp.strftime("%s"))
        self.interaction_history.insert(0, WordInteractionEvent(event_type, seconds_since_epoch))
        self.interaction_history = self.interaction_history[0:MAX_EVENT_HISTORY_LENGTH]
        if self.interaction_history[-1].seconds_since_epoch + timedelta >= seconds_since_epoch:
            self.interaction_history[-1].seconds_since_epoch = seconds_since_epoch
            if event_type == WIH_READ_CLICKED:
                self.interaction_history[-1].event_type = event_type
        elif len(self.interaction_history) < MAX_EVENT_HISTORY_LENGTH:
            self.interaction_history.append(WordInteractionEvent(event_type, seconds_since_epoch))
        else:
            self.interaction_history.append(WordInteractionEvent(event_type, seconds_since_epoch))
            self.interaction_history.pop(0)
def add_event ( self , event_type , timestamp , timedelta = TIMEDELTA ) : seconds_since_epoch = int ( timestamp . strftime ( "%s" ) ) self . interaction_history . insert ( 0 , WordInteractionEvent ( event_type , seconds_since_epoch ) ) self . interaction_history = self . interaction_history [ 0 : MAX_EVENT_HISTORY_LENGTH ] if self . interaction_history [ - 1 ] . seconds_since_epoch + timedelta >= seconds_since_epoch : self . interaction_history [ - 1 ] . seconds_since_epoch = seconds_since_epoch if event_type == WIH_READ_CLICKED : self . interaction_history [ - 1 ] . event_type = event_type elif len ( self . interaction_history ) < MAX_EVENT_HISTORY_LENGTH : self . interaction_history . append ( WordInteractionEvent ( event_type , seconds_since_epoch ) ) else : self . interaction_history . append ( WordInteractionEvent ( event_type , seconds_since_epoch ) ) self . interaction_history . pop ( 0 )
add a new event, no comparison or duplication check involved, use
only if an original event is certain
use for live implementation where time goes in one direction =)
add a new event no comparison or duplication check involved use only if an original event is certain use for live implementation where time goes in one direction = )
"""
            add a new event, no comparison or duplication check involved, use
            only if an original event is certain
            use for live implementation where time goes in one direction =)
        :param event_type:
        :param timestamp:
        :return:
        """ # json can't serialize timestamps, so we simply # change event if an event was already recorded within the timedelta # append if less than 50 events recorded # append new event and pop oldest event
None
self
event_type
None
timestamp
None
timedelta