def _insert_agent_callback_logins_logoffs(self, logins, logoffs): self.session.begin() for login in logins: callback_login = QueueLog( time=login['time'], callid=login['callid'], queuename='NONE', agent=login['agent'], event='AGENTCALLBACKLOGIN', data1=login['chan_name'] ) self.session.add(callback_login) for logoff in logoffs: callback_logoff = QueueLog( time=logoff['time'], callid='NONE', queuename='NONE', agent=logoff['agent'], event='AGENTCALLBACKLOGOFF', data1=logoff['chan_name'], data2=logoff['talktime'].seconds, ) self.session.add(callback_logoff) self.session.commit()
def setUp(self): DAOTestCase.setUp(self) self.callid = '1404377805.6457' self.enterqueue_event = QueueLog( time='2014-07-03 10:57:11.559080', callid=self.callid, queuename='swk_allemagne', agent='NONE', event='ENTERQUEUE', data2='00049242184770', data3='1', ) self.connect_event = QueueLog( time='2014-07-03 10:57:19.461280', callid=self.callid, queuename='swk_allemagne', agent='Agent/448', event='CONNECT', data1='8', data2='1404377831.6460', data3='4', ) self.complete_agent_event = QueueLog( time='2014-07-03 11:06:10.374302', callid=self.callid, queuename='swk_allemagne', agent='Agent/448', event='COMPLETEAGENT', data1='8', data2='531', data3='1', )
def _insert_transferred_call(self, time, callid, qname, aname, waittime, talktime): enterqueue = QueueLog( time=time.strftime(TIMESTAMP_FORMAT), callid=callid, queuename=qname, agent='NONE', event='ENTERQUEUE', data2='1001', data3='1' ) connect = QueueLog( time=(time + datetime.timedelta(seconds=waittime)).strftime(TIMESTAMP_FORMAT), callid=callid, queuename=qname, agent=aname, event='CONNECT', data1=str(waittime), data2='1344965966.141', data3='1' ) transfer = QueueLog( time=(time + datetime.timedelta(seconds=waittime + talktime)).strftime(TIMESTAMP_FORMAT), callid=callid, queuename=qname, agent=aname, event='TRANSFER', data1='s', data2='user', data3=str(waittime), data4=str(talktime) ) self.add_me_all([enterqueue, connect, transfer])
def _insert_completed_call(self, time, callid, qname, aname, waittime, talktime, agent_complete): enterqueue = QueueLog( time=time.strftime(TIMESTAMP_FORMAT), callid=callid, queuename=qname, agent='NONE', event='ENTERQUEUE', data2='1001', data3='1' ) connect = QueueLog( time=(time + datetime.timedelta(seconds=waittime)).strftime(TIMESTAMP_FORMAT), callid=callid, queuename=qname, agent=aname, event='CONNECT', data1=str(waittime), data2='1344965966.141', data3='1' ) complete = QueueLog( time=(time + datetime.timedelta(seconds=waittime + talktime)).strftime(TIMESTAMP_FORMAT), callid=callid, queuename=qname, agent=aname, event='COMPLETEAGENT' if agent_complete else 'COMPLETECALLER', data1=str(waittime), data2=str(talktime) ) self.session.begin() self.session.add_all([enterqueue, connect, complete]) self.session.commit()
def test_get_login_intervals_in_range_no_login_logout_calls(self): connect1 = QueueLog( time=self.start - datetime.timedelta(minutes=5), callid='answered_1', queuename='queue', agent=self.aname1, event='CONNECT', data1='6', data2='linked_callid', data3='2' ) self.session.add(connect1) connect2 = QueueLog( time=self.start + datetime.timedelta(minutes=5), callid='answered_2', queuename='queue', agent=self.aname2, event='CONNECT', data1='6', data2='linked_callid_2', data3='4' ) self.session.begin() self.session.add(connect2) self.session.commit() result = stat_dao.get_login_intervals_in_range(self.session, self.start, self.end) expected = {} self.assertEqual(expected, result)
def setUp(self): DAOTestCase.setUp(self) self._create_functions() self.callid = '1404377805.6457' event = QueueLog( time=t(2020, 1, 1, 0, 0, 0, tzinfo=pytz.UTC), callid=self.callid, queuename='found_queue', event='FULL', ) self.add_me(event) event = QueueLog( time=t(2020, 2, 1, tzinfo=pytz.UTC), callid=self.callid, queuename='ignored_queue', event='CLOSED', ) self.add_me(event)
def _insert_holdtime_call(self, t, callid, qname): call = QueueLog( time=t, callid=callid, queuename=qname, agent='NONE', event='DIVERT_HOLDTIME' ) self.add_me(call)
def _insert_ca_ratio_call(self, t, callid, qname): call = QueueLog( time=t, callid=callid, queuename=qname, agent='NONE', event='DIVERT_CA_RATIO' ) self.add_me(call)
def _insert_closed_call(self, t, callid, qname): closed = QueueLog( time=t.strftime(TIMESTAMP_FORMAT), callid=callid, queuename=qname, agent='NONE', event='CLOSED' ) self.add_me(closed)
def _insert_joinempty_call(self, t, callid, qname): je = QueueLog( time=t.strftime(TIMESTAMP_FORMAT), callid=callid, queuename=qname, agent='NONE', event='JOINEMPTY' ) self.session.add_me(je)
def _insert_full_call(self, t, callid, qname): full = QueueLog( time=t.strftime(TIMESTAMP_FORMAT), callid=callid, queuename=qname, agent='NONE', event='FULL' ) self.add_me(full)
def insert_entry(self, session, queue_log): entry = QueueLog(time=queue_log['time'], callid=queue_log['callid'], queuename=queue_log['queuename'], agent=queue_log['agent'], event=queue_log['event'], data1=queue_log['data1'], data2=queue_log['data2'], data3=queue_log['data3'], data4=queue_log['data4'], data5=queue_log['data5']) session.add(entry)
def _insert_holdtime_call(self, t, callid, qname): call = QueueLog( time=t, callid=callid, queuename=qname, agent='NONE', event='DIVERT_HOLDTIME' ) self.session.begin() self.session.add(call) self.session.commit()
def _insert_leaveempty_call(self, t, callid, qname, waittime): enterqueue = QueueLog( time=t.strftime(TIMESTAMP_FORMAT), callid=callid, queuename=qname, agent='NONE', event='ENTERQUEUE', data2='1000', data3='1' ) leave_time = t + datetime.timedelta(seconds=waittime) le = QueueLog( time=leave_time.strftime(TIMESTAMP_FORMAT), callid=callid, queuename=qname, agent='NONE', event='LEAVEEMPTY' ) self.add_me_all([enterqueue, le])
def _insert_ca_ratio_call(self, t, callid, qname): call = QueueLog( time=t, callid=callid, queuename=qname, agent='NONE', event='DIVERT_CA_RATIO' ) self.session.begin() self.session.add(call) self.session.commit()
def _insert_closed_call(self, t, callid, qname): closed = QueueLog( time=t.strftime(TIMESTAMP_FORMAT), callid=callid, queuename=qname, agent='NONE', event='CLOSED' ) self.session.begin() self.session.add(closed) self.session.commit()
def _insert_full_call(self, t, callid, qname): full = QueueLog( time=t.strftime(TIMESTAMP_FORMAT), callid=callid, queuename=qname, agent='NONE', event='FULL' ) self.session.begin() self.session.add(full) self.session.commit()
def setUp(self): DAOTestCase.setUp(self) self._create_functions() self.callid_found = '1404377805.6457' event = QueueLog( time=t(2020, 1, 1, 0, 0, 0, tzinfo=pytz.UTC), callid=self.callid_found, queuename='found_queue', event='LEAVEEMPTY', ) self.add_me(event) event = QueueLog( time=t(2020, 1, 1, 0, 0, 0, tzinfo=pytz.UTC), callid=self.callid_found, queuename='found_queue', event='ENTERQUEUE', ) self.add_me(event) queue = StatQueue(name='found_queue', tenant_uuid=self.default_tenant.uuid) self.add_me(queue) self.callid_ignored = '1000000000.0000' event = QueueLog( time=t(2020, 2, 1, tzinfo=pytz.UTC), callid=self.callid_ignored, queuename='ignored_queue', event='LEAVEEMPTY', ) self.add_me(event) event = QueueLog( time=t(2020, 2, 1, tzinfo=pytz.UTC), callid=self.callid_ignored, queuename='ignored_queue', event='ENTERQUEUE', ) self.add_me(event) queue = StatQueue(name='ignored_queue', tenant_uuid=self.default_tenant.uuid) self.add_me(queue)
def _insert_agent_logins_logoffs(self, logins, logoffs): with flush_session(self.session): for login in logins: callback_login = QueueLog( time=login['time'], callid=login['callid'], queuename='NONE', agent=login['agent'], event='AGENTLOGIN', data1=login['chan_name'] ) self.session.add(callback_login) for logoff in logoffs: callback_logoff = QueueLog( time=logoff['time'], callid='NONE', queuename='NONE', agent=logoff['agent'], event='AGENTLOGOFF', data1=logoff['chan_name'], data2=logoff['talktime'].seconds, ) self.session.add(callback_logoff)
def _insert_queue_log_data(self, queue_log_data): with flush_session(self.session): lines = queue_log_data.split('\n') lines.pop() header = self._strip_content_list(lines.pop(0).split('|')[1:-1]) for line in lines: tmp = self._strip_content_list(line[1:-1].split('|')) data = dict(zip(header, tmp)) queue_log = QueueLog(time=data['time'], callid=data['callid'], queuename=data['queuename'], agent=data['agent'], event=data['event'], data1=data['data1'], data2=data['data2'], data3=data['data3'], data4=data['data4'], data5=data['data5']) self.session.add(queue_log)
def insert_entry(session, time, callid, queue, agent, event, d1='', d2='', d3='', d4='', d5=''): entry = QueueLog(time=time, callid=callid, queuename=queue, agent=agent, event=event, data1=d1, data2=d2, data3=d3, data4=d4, data5=d5) session.add(entry)
def _insert_entry_queue(self, event, timestamp, callid, queuename, agent=None, d1=None, d2=None, d3=None, d4=None, d5=None): queue_log = QueueLog() queue_log.time = timestamp queue_log.callid = callid queue_log.queuename = queuename queue_log.event = event if agent: queue_log.agent = agent if d1: queue_log.data1 = d1 if d2: queue_log.data2 = d2 if d3: queue_log.data3 = d3 if d4: queue_log.data4 = d4 if d5: queue_log.data5 = d5 self.session.begin() self.session.add(queue_log) self.session.commit()
def _insert_entry_queue(self, event, timestamp, callid, queuename, agent=None, d1=None, d2=None, d3=None, d4=None, d5=None): queue_log = QueueLog() queue_log.time = timestamp queue_log.callid = callid queue_log.queuename = queuename queue_log.event = event if agent: queue_log.agent = agent if d1: queue_log.data1 = d1 if d2: queue_log.data2 = d2 if d3: queue_log.data3 = d3 if d4: queue_log.data4 = d4 if d5: queue_log.data5 = d5 self.session.begin() self.session.add(queue_log) self.session.commit()