def METHOD_NAME(query=None):
    if query is None:
        query = {}
    all_test_executions = TestExecution.objects.filter(**query)
    test_executions = _get_count_for(all_test_executions)
    failed_test_executions = _get_count_for(
        all_test_executions.filter(status__weight__lt=0)
    )
    data = {}
    for value in test_executions:
        data[value["case_id"]] = {
            "case_id": value["case_id"],
            "case_summary": value["case__summary"],
            "count": {"all": value["count"], "fail": 0},
        }
    _count_test_executions(data, failed_test_executions, "fail")
    # remove all with 100% success rate, because they are not interesting
    _remove_all_excellent_executions(data)
    data = list(data.values())
    data.sort(key=_sort_by_failing_rate, reverse=True)
    if len(data) > 30:
        data = data[:30]
    return data