Exemple #1
0
    def push_value(self, item, timestamp, value):
        """Push new value to an item."""
        value_klass = VALUE_CLASS.get(item.itemtype.name, None)

        val = value_klass(item_id=item.id, timestamp=timestamp, value=value)
        self.db_session.add(val)
        return val
Exemple #2
0
    def push_value(self, item, timestamp, value):
        """Push new value to an item."""
        value_klass = VALUE_CLASS.get(item.itemtype.name, None)

        val = value_klass(item_id=item.id, timestamp=timestamp, value=value)
        self.db_session.add(val)
        return val
Exemple #3
0
    def get_last_value(self, item):
        """Return last value published on an item."""
        klass = VALUE_CLASS.get(item.itemtype.name, lambda: "nothing")

        val = self.db_session.query(klass)\
            .filter(klass.item_id == item.id)\
            .order_by(klass.timestamp.desc())\
            .first()

        return val
Exemple #4
0
    def get_last_value(self, item):
        """Return last value published on an item."""
        klass = VALUE_CLASS.get(item.itemtype.name, lambda: "nothing")

        val = self.db_session.query(klass)\
            .filter(klass.item_id == item.id)\
            .order_by(klass.timestamp.desc())\
            .first()

        return val
Exemple #5
0
    def get_values(self, item, start_time=None, end_time=None, count=-1):
        """Query values."""
        klass = VALUE_CLASS.get(item.itemtype.name, "nothing")

        query = self.db_session.query(klass)\
            .filter(klass.item_id == item.id)

        if start_time:
            query = query.filter(klass.timestamp > start_time)

        if end_time:
            query = query.filter(klass.timestamp < end_time)

        values = query.order_by(klass.timestamp.asc()).all()

        return values
Exemple #6
0
    def get_values(self, item, start_time=None, end_time=None, count=-1):
        """Query values."""
        klass = VALUE_CLASS.get(item.itemtype.name, "nothing")

        query = self.db_session.query(klass)\
            .filter(klass.item_id == item.id)

        if start_time:
            query = query.filter(
                klass.timestamp > start_time)

        if end_time:
            query = query.filter(
                klass.timestamp < end_time)

        values = query.order_by(klass.timestamp.asc()).all()

        return values