本文整理汇总了Python中corehq.apps.sms.models.CallLog.wrap方法的典型用法代码示例。如果您正苦于以下问题:Python CallLog.wrap方法的具体用法?Python CallLog.wrap怎么用?Python CallLog.wrap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corehq.apps.sms.models.CallLog
的用法示例。
在下文中一共展示了CallLog.wrap方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_data
# 需要导入模块: from corehq.apps.sms.models import CallLog [as 别名]
# 或者: from corehq.apps.sms.models.CallLog import wrap [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
示例2: get_data
# 需要导入模块: from corehq.apps.sms.models import CallLog [as 别名]
# 或者: from corehq.apps.sms.models.CallLog import wrap [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