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


Python ResponseMappingType.reshape方法代码示例

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


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

示例1: response_view

# 需要导入模块: from fjord.feedback.models import ResponseMappingType [as 别名]
# 或者: from fjord.feedback.models.ResponseMappingType import reshape [as 别名]
def response_view(request, responseid, template):
    response = get_object_or_404(Response, id=responseid)

    try:
        prod = Product.objects.get(db_name=response.product)

        if (not prod.on_dashboard
                and (not request.user.is_authenticated()
                     or not request.user.has_perm(
                         'analytics.can_view_dashboard'))):

            # If this is a response for a hidden product and the user
            # isn't in the analytics group, then they can't see it.
            return HttpResponseForbidden()

    except Product.DoesNotExist:
        pass

    mlt = None
    records = None
    errors = []

    if (request.user.is_authenticated()
            and request.user.has_perm('analytics.can_view_dashboard')):

        try:
            # Convert it to a list to force it to execute right now.
            mlt = ResponseMappingType.reshape(
                ResponseMappingType.morelikethis(response))
        except ElasticsearchException as exc:
            errors.append('Failed to do morelikethis: %s' % exc)

        records = [
            (u'Response records', Record.objects.records(response)),
        ]
        jobs = GengoJob.objects.filter(
            object_id=response.id,
            content_type=ContentType.objects.get_for_model(response)
        )
        for job in jobs:
            records.append(
                (u'Gengo job record {0}'.format(job.id), job.records)
            )

    # We don't pass the response directly to the template and instead
    # do some data tweaks here to make it more palatable for viewing.
    return render(request, template, {
        'errors': errors,
        'response': response,
        'mlt': mlt,
        'records': records,
    })
开发者ID:DerekRies,项目名称:fjord,代码行数:54,代码来源:views.py

示例2: analytics_duplicates

# 需要导入模块: from fjord.feedback.models import ResponseMappingType [as 别名]
# 或者: from fjord.feedback.models.ResponseMappingType import reshape [as 别名]
def analytics_duplicates(request):
    """Shows all duplicate descriptions over the last n days"""
    template = 'analytics/analyzer/duplicates.html'

    n = 14

    responses = (ResponseMappingType.search()
                 .filter(created__gte=datetime.now() - timedelta(days=n))
                 .values_dict('description', 'happy', 'created', 'locale',
                              'user_agent', 'id')
                 .order_by('created').everything())

    responses = ResponseMappingType.reshape(responses)

    total_count = len(responses)

    response_dupes = {}
    for resp in responses:
        response_dupes.setdefault(resp['description'], []).append(resp)

    response_dupes = [
        (key, val) for key, val in response_dupes.items()
        if len(val) > 1
    ]

    # convert the dict into a list of tuples sorted by the number of
    # responses per tuple largest number first
    response_dupes = sorted(response_dupes, key=lambda item: len(item[1]) * -1)

    # duplicate_count -> count
    # i.e. "how many responses had 2 duplicates?"
    summary_counts = defaultdict(int)
    for desc, responses in response_dupes:
        summary_counts[len(responses)] = summary_counts[len(responses)] + 1
    summary_counts = sorted(summary_counts.items(), key=lambda item: item[0])

    return render(request, template, {
        'n': 14,
        'response_dupes': response_dupes,
        'render_time': datetime.now(),
        'summary_counts': summary_counts,
        'total_count': total_count,
    })
开发者ID:DerekRies,项目名称:fjord,代码行数:45,代码来源:analyzer_views.py

示例3: response_view

# 需要导入模块: from fjord.feedback.models import ResponseMappingType [as 别名]
# 或者: from fjord.feedback.models.ResponseMappingType import reshape [as 别名]
def response_view(request, responseid, template):
    response = get_object_or_404(Response, id=responseid)

    mlt = None
    records = None
    errors = []

    if (request.user.is_authenticated()
            and request.user.has_perm('analytics.can_view_dashboard')):

        try:
            # Convert it to a list to force it to execute right now.
            mlt = ResponseMappingType.reshape(
                ResponseMappingType.morelikethis(response))
        except ElasticsearchException as exc:
            errors.append('Failed to do morelikethis: %s' % exc)

        records = [
            (u'Response records', Record.objects.records(response)),
        ]
        jobs = GengoJob.objects.filter(
            object_id=response.id,
            content_type=ContentType.objects.get_for_model(response)
        )
        for job in jobs:
            records.append(
                (u'Gengo job record {0}'.format(job.id), job.records)
            )

    # We don't pass the response directly to the template and instead
    # do some data tweaks here to make it more palatable for viewing.
    return render(request, template, {
        'errors': errors,
        'response': response,
        'mlt': mlt,
        'records': records,
    })
开发者ID:rlr,项目名称:fjord,代码行数:39,代码来源:views.py


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