本文整理汇总了Python中corehq.apps.receiverwrapper.models.RepeatRecord.wrap方法的典型用法代码示例。如果您正苦于以下问题:Python RepeatRecord.wrap方法的具体用法?Python RepeatRecord.wrap怎么用?Python RepeatRecord.wrap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corehq.apps.receiverwrapper.models.RepeatRecord
的用法示例。
在下文中一共展示了RepeatRecord.wrap方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle
# 需要导入模块: from corehq.apps.receiverwrapper.models import RepeatRecord [as 别名]
# 或者: from corehq.apps.receiverwrapper.models.RepeatRecord import wrap [as 别名]
def handle(self, *args, **options):
domain = args[0]
db = Domain.get_db()
doc_ids = get_doc_ids(domain, "RepeatRecord", db)
count = len(doc_ids)
print "found %s doc ids" % count
latest = datetime.min
latest_doc = None
for i, doc in enumerate(iter_docs(db, doc_ids)):
wrapped = RepeatRecord.wrap(doc)
if i % 100 == 0:
print "checked %s / %s" % (i, count)
if wrapped.last_checked and wrapped.last_checked > latest:
latest = wrapped.last_checked
latest_doc = wrapped
print "new latest: %s" % latest
if latest_doc:
print "latest repeater date is %s" % latest
print "latest repeater is %s" % latest_doc._id
else:
print "no relevant repeaters found"
示例2: check_inline_form_repeaters
# 需要导入模块: from corehq.apps.receiverwrapper.models import RepeatRecord [as 别名]
# 或者: from corehq.apps.receiverwrapper.models.RepeatRecord import wrap [as 别名]
def check_inline_form_repeaters(post_fn=None):
"""old-style FormRepeater grandfathered in"""
now = datetime.utcnow()
forms = XFormInstance.view('receiverwrapper/forms_with_pending_repeats',
startkey="",
endkey=json_format_datetime(now),
include_docs=True,
)
for form in forms:
if hasattr(form, 'repeats'):
for repeat_record in form.repeats:
record = dict(repeat_record)
url = record.pop('url')
record = RepeatRecord.wrap(record)
record.payload_id = form.get_id
record._repeater = FormRepeater(url=url)
record.fire(post_fn=post_fn)
record = record.to_json()
record['url'] = url
repeat_record.update(record)
form.save()