def signature_summary(request, params): """Return a list of specific aggregations""" context = {} params["signature"] = "=" + params["signature"][0] params["_aggs.signature"] = [ "hang_type", "process_type", "startup_crash", "dom_fission_enabled", "_histogram.uptime", ] params["_results_number"] = 0 params["_facets"] = [ "platform_pretty_version", "cpu_arch", "process_type", "flash_version", ] params["_histogram.uptime"] = ["product"] params["_histogram_interval.uptime"] = 60 params["_aggs.adapter_vendor_id"] = ["adapter_device_id"] params["_aggs.android_cpu_abi.android_manufacturer.android_model"] = [ "android_version" ] params["_aggs.product.version"] = ["_cardinality.install_time"] # If the user has permissions, show exploitability. all_fields = SuperSearchFields().get() if request.user.has_perms( all_fields["exploitability"]["permissions_needed"]): params["_histogram.date"] = ["exploitability"] api = SuperSearchUnredacted() # Now make the actual request with all expected parameters. try: search_results = api.get(**params) except BadArgumentError as e: # We need to return the error message in some HTML form for jQuery to # pick it up. return http.HttpResponseBadRequest(render_exception(e)) facets = search_results["facets"] _transform_uptime_summary(facets) _transform_graphics_summary(facets) _transform_mobile_summary(facets) _transform_exploitability_summary(facets) context["query"] = search_results context["product_version_total"] = search_results["total"] if "signature" in facets and len(facets["signature"]) > 0: context["signature_stats"] = SignatureStats( search_results["facets"]["signature"][0], search_results["total"]) return render(request, "signature/signature_summary.html", context)
def signature_summary(request, params): """Return a list of specific aggregations""" context = {} params['signature'] = '=' + params['signature'][0] params['_aggs.signature'] = [ 'hang_type', 'process_type', 'startup_crash', '_histogram.uptime', ] params['_results_number'] = 0 params['_facets'] = [ 'platform_pretty_version', 'cpu_arch', 'process_type', 'flash_version', ] params['_histogram.uptime'] = ['product'] params['_histogram_interval.uptime'] = 60 params['_aggs.adapter_vendor_id'] = ['adapter_device_id'] params['_aggs.android_cpu_abi.android_manufacturer.android_model'] = [ 'android_version' ] params['_aggs.product.version'] = ['_cardinality.install_time'] # If the user has permissions, show exploitability. all_fields = SuperSearchFields().get() if has_permissions( request.user, all_fields['exploitability']['permissions_needed'] ): params['_histogram.date'] = ['exploitability'] api = SuperSearchUnredacted() # Now make the actual request with all expected parameters. try: search_results = api.get(**params) except BadArgumentError as e: # We need to return the error message in some HTML form for jQuery to # pick it up. return http.HttpResponseBadRequest(render_exception(e)) facets = search_results['facets'] _transform_uptime_summary(facets) _transform_graphics_summary(facets) _transform_mobile_summary(facets) _transform_exploitability_summary(facets) context['query'] = search_results context['product_version_total'] = search_results['total'] if 'signature' in facets and len(facets['signature']) > 0: context['signature_stats'] = SignatureStats(search_results['facets']['signature'][0], search_results['total']) return render(request, 'signature/signature_summary.html', context)
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
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