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


Python ResponseMappingType.extract_document方法代码示例

本文整理汇总了Python中fjord.feedback.models.ResponseMappingType.extract_document方法的典型用法代码示例。如果您正苦于以下问题:Python ResponseMappingType.extract_document方法的具体用法?Python ResponseMappingType.extract_document怎么用?Python ResponseMappingType.extract_document使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在fjord.feedback.models.ResponseMappingType的用法示例。


在下文中一共展示了ResponseMappingType.extract_document方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: timezone_view

# 需要导入模块: from fjord.feedback.models import ResponseMappingType [as 别名]
# 或者: from fjord.feedback.models.ResponseMappingType import extract_document [as 别名]
def timezone_view(request):
    """Admin view showing times and timezones in data."""
    # Note: This is an admin page that gets used once in a blue moon.
    # As such, I'm taking some liberties (hand-indexing the response,
    # time.sleep, etc) that I would never take if it was used more
    # often or was viewable by users. If these two assumptions ever
    # change, then this should be rewritten.

    from elasticutils.contrib.django import get_es

    from fjord.feedback.models import Response, ResponseMappingType
    from fjord.feedback.tests import ResponseFactory
    from fjord.search.index import get_index

    server_time = datetime.now()

    # Create a new response.
    resp = ResponseFactory.create()
    resp_time = resp.created

    # Index the response by hand so we know it gets to Elasticsearch. Otherwise
    # it gets done by celery and we don't know how long that'll take.
    doc = ResponseMappingType.extract_document(resp.id)
    ResponseMappingType.index(doc, resp.id)

    # Fetch the response from the db.
    resp = Response.objects.get(id=resp.id)
    resp2_time = resp.created

    # Refresh and sleep 5 seconds as a hand-wavey way to make sure
    # that Elasticsearch has had time to refresh the index.
    get_es().indices.refresh(get_index())
    time.sleep(5)

    es_time = ResponseMappingType.search().filter(id=resp.id)[0].created

    # Delete the test response we created.
    resp.delete()

    return render(request, 'admin/timezone_view.html', {
        'server_time': server_time,
        'resp_time': resp_time,
        'resp2_time': resp2_time,
        'es_time': es_time
    })
开发者ID:rlr,项目名称:fjord,代码行数:47,代码来源:admin.py


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