Ejemplo n.º 1
0
def remove_between(dao_sess, start, end):
    logger.info('Removing queue cache between %s - %s', start, end)
    callids = stat_call_on_queue_dao.find_all_callid_between_date(
        dao_sess, start, end)
    if callids:
        stat_call_on_queue_dao.remove_callids(dao_sess, callids)
    stat_queue_periodic_dao.remove_after(dao_sess, start)
Ejemplo n.º 2
0
    def test_remove_after(self):
        queue_name, queue_id = self._insert_queue_to_stat_queue()
        stats = {queue_id: {'full': 4, 'total': 10}}

        with flush_session(self.session):
            stat_queue_periodic_dao.insert_stats(self.session, stats,
                                                 dt(2012, 1, 1, tzinfo=UTC))
            stat_queue_periodic_dao.insert_stats(self.session, stats,
                                                 dt(2012, 1, 2, tzinfo=UTC))
            stat_queue_periodic_dao.insert_stats(self.session, stats,
                                                 dt(2012, 1, 3, tzinfo=UTC))

        stat_queue_periodic_dao.remove_after(self.session,
                                             dt(2012, 1, 2, tzinfo=UTC))

        res = self.session.query(StatQueuePeriodic.time)

        self.assertEqual(res.count(), 1)
        self.assertEqual(res[0].time, dt(2012, 1, 1, tzinfo=UTC))
Ejemplo n.º 3
0
    def test_remove_after(self):
        queue_name, queue_id = self._insert_queue_to_stat_queue()
        stats = {queue_id: {'full': 4, 'total': 10}}

        self.session.begin()
        stat_queue_periodic_dao.insert_stats(self.session, stats,
                                             datetime.datetime(2012, 1, 1))
        stat_queue_periodic_dao.insert_stats(self.session, stats,
                                             datetime.datetime(2012, 1, 2))
        stat_queue_periodic_dao.insert_stats(self.session, stats,
                                             datetime.datetime(2012, 1, 3))
        self.session.commit()

        stat_queue_periodic_dao.remove_after(self.session,
                                             datetime.datetime(2012, 1, 2))

        res = self.session.query(StatQueuePeriodic.time)

        self.assertEqual(res.count(), 1)
        self.assertEqual(res[0].time, datetime.datetime(2012, 1, 1))
    def test_remove_after(self):
        queue_name, queue_id = self._insert_queue_to_stat_queue()
        stats = {
            queue_id: {
                'full': 4,
                'total': 10
            }
        }

        with flush_session(self.session):
            stat_queue_periodic_dao.insert_stats(self.session, stats, datetime.datetime(2012, 1, 1))
            stat_queue_periodic_dao.insert_stats(self.session, stats, datetime.datetime(2012, 1, 2))
            stat_queue_periodic_dao.insert_stats(self.session, stats, datetime.datetime(2012, 1, 3))

        stat_queue_periodic_dao.remove_after(self.session, datetime.datetime(2012, 1, 2))

        res = self.session.query(StatQueuePeriodic.time)

        self.assertEqual(res.count(), 1)
        self.assertEqual(res[0].time, datetime.datetime(2012, 1, 1))
Ejemplo n.º 5
0
def remove_between(dao_sess, start, end):
    logger.info('Removing queue cache between %s - %s', start, end)
    callids = stat_call_on_queue_dao.find_all_callid_between_date(dao_sess, start, end)
    if callids:
        stat_call_on_queue_dao.remove_callids(dao_sess, callids)
    stat_queue_periodic_dao.remove_after(dao_sess, start)