def stats_data(request): histo_type = request.GET.get('histogram_type') interval = request.GET.get("interval", "week") datefield = request.GET.get("datefield") individual_domain_limit = request.GET.get("individual_domain_limit[]") or 16 if not request.GET.get("enddate"): # datespan should include up to the current day when unspecified request.datespan.enddate += timedelta(days=1) params, __ = parse_args_for_es(request, prefix='es_') if histo_type == "domains": return json_response(get_domain_stats_data(params, request.datespan, interval=interval, datefield=datefield)) if params: domain_results = es_domain_query(params, fields=["name"], size=99999, show_stats=False) domains = [d["fields"]["name"] for d in domain_results["hits"]["hits"]] if len(domains) <= individual_domain_limit: domain_info = [{"names": [d], "display_name": d} for d in domains] elif len(domains) < ES_MAX_CLAUSE_COUNT: domain_info = [{"names": [d for d in domains], "display_name": _("Domains Matching Filter")}] else: domain_info = [{ "names": None, "display_name": _("All Domains (NOT applying filters. > %s projects)" % ES_MAX_CLAUSE_COUNT) }] else: domain_info = [{"names": None, "display_name": _("All Domains")}] stats_data = get_stats_data(domain_info, histo_type, request.datespan, interval=interval) return json_response(stats_data)
def stats_data(request, org): domains = [{ "names": [d.name], "display_name": d.hr_name } for d in Domain.get_by_organization(org)] histo_type = request.GET.get('histogram_type') interval = request.GET.get('interval', 'day') stats_data = get_stats_data(domains, histo_type, request.datespan, interval=interval) return json_response(stats_data)
def stats_data(request): histo_type = request.GET.get('histogram_type') interval = request.GET.get("interval", "week") datefield = request.GET.get("datefield") individual_domain_limit = request.GET.get( "individual_domain_limit[]") or 16 if not request.GET.get( "enddate" ): # datespan should include up to the current day when unspecified request.datespan.enddate += timedelta(days=1) params, __ = parse_args_for_es(request, prefix='es_') if histo_type == "domains": return json_response( get_domain_stats_data(params, request.datespan, interval=interval, datefield=datefield)) if params: domain_results = es_domain_query(params, fields=["name"], size=99999, show_stats=False) domains = [d["fields"]["name"] for d in domain_results["hits"]["hits"]] if len(domains) <= individual_domain_limit: domain_info = [{"names": [d], "display_name": d} for d in domains] elif len(domains) < ES_MAX_CLAUSE_COUNT: domain_info = [{ "names": [d for d in domains], "display_name": _("Domains Matching Filter") }] else: domain_info = [{ "names": None, "display_name": _("All Domains (NOT applying filters. > %s projects)" % ES_MAX_CLAUSE_COUNT) }] else: domain_info = [{"names": None, "display_name": _("All Domains")}] stats_data = get_stats_data(domain_info, histo_type, request.datespan, interval=interval) return json_response(stats_data)
def stats_data(request, org): domains = [{"names": [d.name], "display_name": d.hr_name} for d in Domain.get_by_organization(org)] histo_type = request.GET.get('histogram_type') interval = request.GET.get('interval', 'day') stats_data = get_stats_data(domains, histo_type, request.datespan, interval=interval) return json_response(stats_data)