当前位置: 首页>>代码示例>>Python>>正文


Python CallLog.get_db方法代码示例

本文整理汇总了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-'))
开发者ID:ansarbek,项目名称:commcare-hq,代码行数:30,代码来源:migration.py

示例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
开发者ID:aristide,项目名称:commcare-hq,代码行数:29,代码来源:ivr_usage.py

示例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
开发者ID:LifeCoaching,项目名称:commcare-hq,代码行数:43,代码来源:ivr_usage.py

示例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
开发者ID:saketkanth,项目名称:commcare-hq,代码行数:24,代码来源:delete_messaging_couch_logs.py

示例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
         ])
开发者ID:philipkaare,项目名称:commcare-hq,代码行数:8,代码来源:util.py


注:本文中的corehq.apps.sms.models.CallLog.get_db方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。