How to use the memorious.core.session.query function in memorious

To help you get started, we’ve selected a few memorious examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alephdata / memorious / memorious / model / operation.py View on Github external
def check_rate(cls, crawler, stage, sample=1):
        q = session.query(func.count(cls.id))
        q = q.filter(cls.crawler == crawler)
        q = q.filter(cls.name == stage)
        period = timedelta(seconds=sample * 60)
        start = datetime.utcnow() - period
        q = q.filter(cls.started_at >= start)
        count = q.scalar()
        return (float(count) / sample) / 60.0
github alephdata / memorious / memorious / model / operation.py View on Github external
def last_run(cls, crawler):
        q = session.query(cls)
        q = q.filter(cls.crawler == crawler)
        q = q.order_by(cls.started_at.desc())
        op = q.first()
        if op is None:
            return None
        return op.started_at
github alephdata / memorious / memorious / model / result.py View on Github external
def delete(cls, crawler):
        pq = session.query(cls)
        pq = pq.filter(cls.crawler == crawler)
        pq.delete(synchronize_session=False)
github alephdata / memorious / memorious / model / operation.py View on Github external
def last_status(cls, crawler):
        q = session.query(cls)
        q = q.filter(cls.crawler == crawler)
        q = q.order_by(cls.started_at.desc())
        op = q.first()
        if op is None:
            return None
        return op.status
github alephdata / memorious / memorious / model / operation.py View on Github external
def get(cls, **kwargs):
        q = session.query(cls)
        q = q.filter_by(**kwargs)
        return q.all()
github alephdata / memorious / memorious / model / operation.py View on Github external
def delete(cls, crawler):
        from memorious.model.event import Event
        from memorious.model.result import Result
        Event.delete(crawler)
        Result.delete(crawler)
        pq = session.query(cls)
        pq = pq.filter(cls.crawler == crawler)
        pq.delete(synchronize_session=False)