Ejemplo n.º 1
0
class Step(BaseDocument):
    """ Module represents persistent Model for a single step in a flow """

    db_id = ObjectIdField(name='_id', null=True)
    flow_name = StringField()
    step_name = StringField()
    timeperiod = StringField(null=True)
    state = StringField(choices=[
        STATE_INVALID, STATE_EMBRYO, STATE_IN_PROGRESS, STATE_PROCESSED,
        STATE_CANCELED, STATE_NOOP
    ])
    created_at = DateTimeField()
    started_at = DateTimeField()
    finished_at = DateTimeField()

    related_flow = ObjectIdField()

    @classmethod
    def key_fields(cls):
        return cls.flow_name.name, cls.step_name.name, cls.timeperiod.name

    @property
    def is_failed(self):
        return self.state in [STATE_INVALID, STATE_CANCELED]

    @property
    def is_processed(self):
        return self.state == STATE_PROCESSED

    @property
    def is_in_progress(self):
        return self.state == STATE_IN_PROGRESS
Ejemplo n.º 2
0
class Step(BaseDocument):
    """ Module represents persistent Model for a single step in a flow """

    db_id = ObjectIdField('_id', null=True)
    flow_name = StringField(FLOW_NAME)
    step_name = StringField(STEP_NAME)
    timeperiod = StringField(TIMEPERIOD, null=True)
    state = StringField(STATE,
                        choices=[
                            STATE_INVALID, STATE_EMBRYO, STATE_IN_PROGRESS,
                            STATE_PROCESSED, STATE_CANCELED, STATE_NOOP
                        ])
    created_at = DateTimeField(CREATED_AT)
    started_at = DateTimeField(STARTED_AT)
    finished_at = DateTimeField(FINISHED_AT)

    related_flow = ObjectIdField(RELATED_FLOW)

    @property
    def key(self):
        return self.flow_name, self.step_name, self.timeperiod

    @property
    def is_failed(self):
        return self.state in [STATE_INVALID, STATE_CANCELED]

    @property
    def is_processed(self):
        return self.state == STATE_PROCESSED

    @property
    def is_in_progress(self):
        return self.state == STATE_IN_PROGRESS
Ejemplo n.º 3
0
class Flow(BaseDocument):
    """ class presents status for a Flow run """

    db_id = ObjectIdField(name='_id', null=True)
    flow_name = StringField()
    timeperiod = StringField()
    start_timeperiod = StringField()
    end_timeperiod = StringField()
    state = StringField(choices=[
        STATE_EMBRYO, STATE_IN_PROGRESS, STATE_PROCESSED, STATE_NOOP,
        STATE_INVALID
    ])

    # run_mode override rules:
    # - default value is read from ProcessEntry.arguments['run_mode']
    # - if the ProcessEntry.arguments['run_mode'] is None then run_mode is assumed `run_mode_nominal`
    # - Flow.run_mode, if specified, overrides ProcessEntry.arguments['run_mode']
    # - UOW.arguments['run_mode'] overrides Flow.run_mode
    run_mode = StringField(choices=[RUN_MODE_NOMINAL, RUN_MODE_RECOVERY])

    created_at = DateTimeField()
    started_at = DateTimeField()
    finished_at = DateTimeField()

    @classmethod
    def key_fields(cls):
        return cls.flow_name.name, cls.timeperiod.name
Ejemplo n.º 4
0
class Flow(BaseDocument):
    """ class presents status for a Flow run """

    db_id = ObjectIdField('_id', null=True)
    flow_name = StringField(FLOW_NAME)
    timeperiod = StringField(TIMEPERIOD)
    start_timeperiod = StringField(START_TIMEPERIOD)
    end_timeperiod = StringField(END_TIMEPERIOD)
    state = StringField(STATE,
                        choices=[
                            STATE_EMBRYO, STATE_IN_PROGRESS, STATE_PROCESSED,
                            STATE_NOOP, STATE_INVALID
                        ])

    # run_mode override rules:
    # - default value is read from ProcessEntry.arguments['run_mode']
    # - if the ProcessEntry.arguments['run_mode'] is None then run_mode is assumed `run_mode_nominal`
    # - Flow.run_mode, if specified, overrides ProcessEntry.arguments['run_mode']
    # - UOW.arguments['run_mode'] overrides Flow.run_mode
    run_mode = StringField(RUN_MODE,
                           choices=[RUN_MODE_NOMINAL, RUN_MODE_RECOVERY])

    created_at = DateTimeField(CREATED_AT)
    started_at = DateTimeField(STARTED_AT)
    finished_at = DateTimeField(FINISHED_AT)

    @BaseDocument.key.getter
    def key(self):
        return self.flow_name, self.timeperiod

    @key.setter
    def key(self, value):
        """ :param value: tuple (name of the flow, timeperiod as string in Synergy Data format) """
        self.flow_name = value[0]
        self.timeperiod = value[1]
Ejemplo n.º 5
0
class SiteStatistics(BaseDocument):
    """
    class presents site statistics, such as number of visits per defined period or list of search keywords
    """

    db_id = ObjectIdField('_id', null=True)
    domain_name = StringField(DOMAIN_NAME)
    timeperiod = StringField(TIMEPERIOD)
    stat = NestedDocumentField(FAMILY_STAT, NestedStat)

    @BaseDocument.key.getter
    def key(self):
        return self.domain_name, self.timeperiod

    @key.setter
    def key(self, value):
        self.domain_name = value[0]
        self.timeperiod = value[1]
Ejemplo n.º 6
0
class Alert(BaseDocument):
    """
    class presents model describing an Alert event, such as 20% increase or decrease in the page views
    """

    db_id = ObjectIdField('_id', null=True)
    domain_name = StringField(DOMAIN_NAME)
    timeperiod = StringField(TIMEPERIOD)
    number_of_pageviews = IntegerField(NUMBER_OF_PAGEVIEWS)
    number_of_visits = IntegerField(NUMBER_OF_VISITS)

    @BaseDocument.key.getter
    def key(self):
        return self.domain_name, self.timeperiod

    @key.setter
    def key(self, value):
        """
        :param value: tuple (domain_name <string>, timeperiod <string in YYYYMMDDHH format>)
        """
        self.domain_name = value[0]
        self.timeperiod = value[1]
Ejemplo n.º 7
0
class SingleSession(BaseDocument):
    """
    class presents statistics, gathered during the life of the session
    """

    db_id = ObjectIdField('_id', null=True)
    domain_name = StringField(DOMAIN_NAME)
    timeperiod = StringField(TIMEPERIOD)
    session_id = StringField(SESSION_ID)
    user_profile = NestedDocumentField(FAMILY_USER_PROFILE, NestedUserProfile)
    browsing_history = NestedDocumentField(FAMILY_BROWSING_HISTORY,
                                           NestedBrowsingHistory)

    @BaseDocument.key.getter
    def key(self):
        return self.domain_name, self.timeperiod, self.session_id

    @key.setter
    def key(self, value):
        self.domain_name = value[0]
        self.timeperiod = value[1]
        self.session_id = value[2]