本文整理汇总了Python中corehq.apps.sms.models.CallLog.get_db方法的典型用法代码示例。如果您正苦于以下问题:Python CallLog.get_db方法的具体用法?Python CallLog.get_db怎么用?Python CallLog.get_db使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corehq.apps.sms.models.CallLog
的用法示例。
在下文中一共展示了CallLog.get_db方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testCallSync
# 需要导入模块: from corehq.apps.sms.models import CallLog [as 别名]
# 或者: from corehq.apps.sms.models.CallLog import get_db [as 别名]
def testCallSync(self):
self.deleteAllLogs()
self.assertEqual(self.getCallLogCount(), 0)
self.assertEqual(self.getCallCount(), 0)
# Test Create
call = Call()
self.setRandomCallValues(call)
call.save()
sleep(1)
self.assertEqual(self.getCallLogCount(), 1)
self.assertEqual(self.getCallCount(), 1)
calllog = CallLog.get(call.couch_id)
self.checkFieldValues(calllog, call, Call._migration_get_fields())
self.assertTrue(CallLog.get_db().get_rev(calllog._id).startswith('2-'))
# Test Update
self.setRandomCallValues(call)
call.save()
sleep(1)
self.assertEqual(self.getCallLogCount(), 1)
self.assertEqual(self.getCallCount(), 1)
callog = CallLog.get(call.couch_id)
self.checkFieldValues(callog, call, Call._migration_get_fields())
self.assertTrue(CallLog.get_db().get_rev(callog._id).startswith('3-'))
示例2: get_data
# 需要导入模块: from corehq.apps.sms.models import CallLog [as 别名]
# 或者: from corehq.apps.sms.models.CallLog import get_db [as 别名]
def get_data(ids):
"""
returns the data in the format:
{
'2015-03': {
'domain1': {
'KOOKOO': {'calls': 40, 'minutes': 45}
},
'domain2': {
'KOOKOO': {'calls': 20, 'minutes': 25}
'TELERIVET': {'calls': 5, 'minutes': 0}
}
}
}
"""
data = {}
for doc in iter_docs(CallLog.get_db(), ids):
call = CallLog.wrap(doc)
month_data = get_month_data(data, call.date)
domain_data = get_domain_data(month_data, call.domain)
backend_api = get_backend_api(call)
backend_data = get_backend_data(domain_data, backend_api)
backend_data['calls'] += 1
duration = (call.duration or 0) / 60.0
duration = int(ceil(duration))
backend_data['minutes'] += duration
return data
示例3: get_data
# 需要导入模块: from corehq.apps.sms.models import CallLog [as 别名]
# 或者: from corehq.apps.sms.models.CallLog import get_db [as 别名]
def get_data(ids, timezone=None):
"""
returns the data in the format:
{
'2015-03': {
'domain1': {
'KOOKOO': {
'I': {'calls': 2, 'minutes': 3},
'O': {'calls': 40, 'minutes': 45},
'?': {'calls': 0, 'minutes': 0},
},
},
'domain2': {
'KOOKOO': {
'I': {'calls': 1, 'minutes': 1},
'O': {'calls': 20, 'minutes': 25},
'?': {'calls': 0, 'minutes': 0},
},
'TELERIVET': {
'I': {'calls': 10, 'minutes': 0},
'O': {'calls': 0, 'minutes': 0},
'?': {'calls': 0, 'minutes': 0},
},
}
}
}
"""
data = {}
for doc in iter_docs(CallLog.get_db(), ids):
call = CallLog.wrap(doc)
date = get_naive_user_datetime(call.date, timezone=timezone)
month_data = get_month_data(data, date)
domain_data = get_domain_data(month_data, call.domain)
backend_api = get_backend_api(call)
backend_data = get_backend_data(domain_data, backend_api)
direction = get_direction(call)
backend_data[direction]['calls'] += 1
duration = (call.duration or 0) / 60.0
duration = int(ceil(duration))
backend_data[direction]['minutes'] += duration
return data
示例4: delete_models
# 需要导入模块: from corehq.apps.sms.models import CallLog [as 别名]
# 或者: from corehq.apps.sms.models.CallLog import get_db [as 别名]
def delete_models(self, delete_interval):
print 'Deleting SMSLogs...'
count = iter_bulk_delete_with_doc_type_verification(SMSLog.get_db(), self.get_sms_couch_ids(), 'SMSLog',
wait_time=delete_interval, max_fetch_attempts=5)
print 'Deleted %s documents' % count
print 'Deleting CallLogs...'
count = iter_bulk_delete_with_doc_type_verification(CallLog.get_db(), self.get_call_couch_ids(), 'CallLog',
wait_time=delete_interval, max_fetch_attempts=5)
print 'Deleted %s documents' % count
print 'Deleting ExpectedCallbackEventLogs...'
count = iter_bulk_delete_with_doc_type_verification(ExpectedCallbackEventLog.get_db(),
self.get_callback_couch_ids(), 'ExpectedCallbackEventLog', wait_time=delete_interval,
max_fetch_attempts=5)
print 'Deleted %s documents' % count
print 'Deleting LastReadMessages...'
count = iter_bulk_delete_with_doc_type_verification(LastReadMessage.get_db(),
self.get_lastreadmessage_couch_ids(), 'LastReadMessage', wait_time=delete_interval,
max_fetch_attempts=5)
print 'Deleted %s documents' % count
示例5: delete_call_logs
# 需要导入模块: from corehq.apps.sms.models import CallLog [as 别名]
# 或者: from corehq.apps.sms.models.CallLog import get_db [as 别名]
def delete_call_logs(self, domain):
calls = CallLog.by_domain_asc(domain).all()
if calls:
CallLog.get_db().bulk_delete([
call.to_json() for call in calls
])