<commit_before>import mysite.search.models
import mysite.search.views
import collections

def discover_available_facets(query_words=[]):
    """
    Returns facet2value2count
    """
    bugs = mysite.search.views.get_bugs_by_query_words(query_words)

    if not bugs:
        return []

    # The languages facet is based on the project languages, "for now"
    ret = {}
    ret['Language'] = collections.defaultdict(int)
    projects = bugs.only('project').distinct()
    for p in projects:
        ret['Language'][p.language] = 0 # This is to be used for the count. A a a.

    #for bug in bugs:
    #   ret['Language'][bug.project.language] += 1

    # convert from defaultdict so items will work in dj templates.
    ret['Language'] = dict(ret['Language']) 

    return ret<commit_msg>wip: use select distinct correctly.<commit_after>import mysite.search.models
import mysite.search.views
import collections

def discover_available_facets(query_words=[]):
    """
    Returns facet2value2count
    """
    bugs = mysite.search.views.get_bugs_by_query_words(query_words)

    if not bugs:
        return []

    # The languages facet is based on the project languages, "for now"
    ret = {}
    ret['Language'] = collections.defaultdict(int)
    bugs = bugs.only('project').distinct()
    for b in bugs:
        ret['Language'][b.project.language] = 0 # This is to be used for the count. A a a.

    #for bug in bugs:
    #   ret['Language'][bug.project.language] += 1

    # convert from defaultdict so items will work in dj templates.
    ret['Language'] = dict(ret['Language']) 

    return ret
{'fraction_non_alphanumeric': 0.11423220973782772, 'fraction_numerical': 0.004993757802746567, 'mean_word_length': 3.2746666666666666, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5804042', 'n_tokens_mistral': 491, 'n_tokens_neox': 472, 'n_words': 141}