本文整理汇总了Python中corehq.apps.receiverwrapper.models.CaseRepeater.get方法的典型用法代码示例。如果您正苦于以下问题:Python CaseRepeater.get方法的具体用法?Python CaseRepeater.get怎么用?Python CaseRepeater.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corehq.apps.receiverwrapper.models.CaseRepeater
的用法示例。
在下文中一共展示了CaseRepeater.get方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle
# 需要导入模块: from corehq.apps.receiverwrapper.models import CaseRepeater [as 别名]
# 或者: from corehq.apps.receiverwrapper.models.CaseRepeater import get [as 别名]
def handle(self, *args, **options):
domain = 'care-bihar'
# forward all cases that were last modified between these dates
def should_forward_case(case):
min_date = datetime(2013, 9, 10)
max_date = datetime(2013, 11, 7)
return (case.server_modified_on
and min_date < case.server_modified_on < max_date)
prod_repeater = CaseRepeater.get('a478a5a3d8964338cb3124de77e3ec58')
success_count = 0
fail_count = 0
for case in get_cases_in_domain(domain):
try:
if should_forward_case(case):
prod_repeater.register(case)
success_count += 1
except Exception:
fail_count += 1
logging.exception('problem creating repeater stub for case %s' % case._id)
print 'successfully forwarded %s cases. %s were not processed' % (success_count, fail_count)