コード例 #1
0
ファイル: views.py プロジェクト: richev/socorro
def get_topcrashers_stats(**kwargs):
    """Return the results of a search. """
    params = kwargs
    range_type = params.pop("_range_type")
    dates = get_date_boundaries(params)

    params["_aggs.signature"] = [
        "platform",
        "is_garbage_collecting",
        "hang_type",
        "process_type",
        "startup_crash",
        "_histogram.uptime",
        "_cardinality.install_time",
    ]
    params["_histogram_interval.uptime"] = 60

    # We don't care about no results, only facets.
    params["_results_number"] = 0

    if params.get("process_type") in ("any", "all"):
        params["process_type"] = None

    if range_type == "build":
        params["build_id"] = [
            ">=" + datetime_to_build_id(dates[0]),
            "<" + datetime_to_build_id(dates[1]),
        ]

    api = SuperSearchUnredacted()
    search_results = api.get(**params)

    signatures_stats = []
    if search_results["total"] > 0:
        # Run the same query but for the previous date range, so we can
        # compare the rankings and show rank changes.
        delta = (dates[1] - dates[0]) * 2
        params["date"] = [
            ">=" + (dates[1] - delta).isoformat(),
            "<" + dates[0].isoformat(),
        ]
        params["_aggs.signature"] = ["platform"]
        params["_facets_size"] *= 2

        if range_type == "build":
            params["date"][1] = "<" + dates[1].isoformat()
            params["build_id"] = [
                ">=" + datetime_to_build_id(dates[1] - delta),
                "<" + datetime_to_build_id(dates[0]),
            ]

        previous_range_results = api.get(**params)
        previous_signatures = get_comparison_signatures(previous_range_results)

        for index, signature in enumerate(
                search_results["facets"]["signature"]):
            previous_signature = previous_signatures.get(signature["term"])
            signatures_stats.append(
                SignatureStats(
                    signature=signature,
                    num_total_crashes=search_results["total"],
                    rank=index,
                    platforms=models.Platform.objects.values(),
                    previous_signature=previous_signature,
                ))
    return signatures_stats
コード例 #2
0
def get_topcrashers_stats(**kwargs):
    """Return the results of a search. """
    params = kwargs
    range_type = params.pop('_range_type')
    dates = get_date_boundaries(params)

    params['_aggs.signature'] = [
        'platform',
        'is_garbage_collecting',
        'hang_type',
        'process_type',
        'startup_crash',
        '_histogram.uptime',
        '_cardinality.install_time',
    ]
    params['_histogram_interval.uptime'] = 60

    # We don't care about no results, only facets.
    params['_results_number'] = 0

    if params.get('process_type') in ('any', 'all'):
        params['process_type'] = None

    if range_type == 'build':
        params['build_id'] = [
            '>=' + datetime_to_build_id(dates[0]),
            '<' + datetime_to_build_id(dates[1])
        ]

    api = SuperSearchUnredacted()
    search_results = api.get(**params)

    signatures_stats = []
    if search_results['total'] > 0:
        # Run the same query but for the previous date range, so we can
        # compare the rankings and show rank changes.
        delta = (dates[1] - dates[0]) * 2
        params['date'] = [
            '>=' + (dates[1] - delta).isoformat(),
            '<' + dates[0].isoformat()
        ]
        params['_aggs.signature'] = [
            'platform',
        ]
        params['_facets_size'] *= 2

        if range_type == 'build':
            params['date'][1] = '<' + dates[1].isoformat()
            params['build_id'] = [
                '>=' + datetime_to_build_id(dates[1] - delta),
                '<' + datetime_to_build_id(dates[0])
            ]

        previous_range_results = api.get(**params)
        previous_signatures = get_comparison_signatures(previous_range_results)

        for index, signature in enumerate(search_results['facets']['signature']):
            previous_signature = previous_signatures.get(signature['term'])
            signatures_stats.append(SignatureStats(
                signature=signature,
                num_total_crashes=search_results['total'],
                rank=index,
                platforms=models.Platform.objects.values(),
                previous_signature=previous_signature,
            ))
    return signatures_stats