<commit_before>from datetime import datetime
from django.contrib import messages
import logging
from corehq.apps.announcements.models import ReportAnnouncement
from corehq.apps.groups.models import Group
from corehq.apps.reports.display import xmlns_to_name
from corehq.apps.reports.models import HQUserType, TempCommCareUser
from corehq.apps.users.models import CommCareUser, CouchUser
from corehq.apps.users.util import user_id_to_username
from couchexport.util import SerializableFunction
from couchforms.filters import instances
from dimagi.utils.couch.database import get_db
from dimagi.utils.dates import DateSpan
from dimagi.utils.modules import to_function
from django.http import Http404
import pytz
from corehq.apps.domain.models import Domain
from corehq.apps.users.models import WebUser
from dimagi.utils.timezones import utils as tz_utils
from dimagi.utils.web import json_request
from django.conf import settings

def make_form_couch_key(domain, by_submission_time=True,
                   xmlns=None, user_id=Ellipsis, app_id=None):
    prefix = ["submission"] if by_submission_time else ["completion"]
    key = [domain] if domain is not None else []
    if xmlns == "":
        prefix.append('xmlns')
    elif app_id == "":
        prefix.append('app')
    elif user_id == "":
        prefix.append('user')
    else:
        if xmlns:
            prefix.append('xmlns')
            key.append(xmlns)
        if app_id:
            prefix.append('app')
            key.append(app_id)
        if user_id is not Ellipsis:
            prefix.append('user')
            key.append(user_id)
    return [" ".join(prefix)] + key

def all_xmlns_in_domain(domain):<commit_msg>added comment<commit_after>from datetime import datetime
from django.contrib import messages
import logging
from corehq.apps.announcements.models import ReportAnnouncement
from corehq.apps.groups.models import Group
from corehq.apps.reports.display import xmlns_to_name
from corehq.apps.reports.models import HQUserType, TempCommCareUser
from corehq.apps.users.models import CommCareUser, CouchUser
from corehq.apps.users.util import user_id_to_username
from couchexport.util import SerializableFunction
from couchforms.filters import instances
from dimagi.utils.couch.database import get_db
from dimagi.utils.dates import DateSpan
from dimagi.utils.modules import to_function
from django.http import Http404
import pytz
from corehq.apps.domain.models import Domain
from corehq.apps.users.models import WebUser
from dimagi.utils.timezones import utils as tz_utils
from dimagi.utils.web import json_request
from django.conf import settings


def make_form_couch_key(domain, by_submission_time=True,
                   xmlns=None, user_id=Ellipsis, app_id=None):
    """
        This sets up the appropriate query for couch based on common report parameters.

        Note: Ellipsis is used as the default for user_id because
        None is actually emitted as a user_id on occasion in couch
    """
    prefix = ["submission"] if by_submission_time else ["completion"]
    key = [domain] if domain is not None else []
    if xmlns == "":
        prefix.append('xmlns')
    elif app_id == "":
        prefix.append('app')
    elif user_id == "":
        prefix.append('user')
    else:
        if xmlns:
            prefix.append('xmlns')
            key.append(xmlns)
        if app_id:
            prefix.append('app')
            key.append(app_id)
        if user_id is not Ellipsis:
            prefix.append('user')
            key.append(user_id)
    return [" ".join(prefix)] + key


def all_xmlns_in_domain(domain):
{'fraction_non_alphanumeric': 0.079312257348863, 'fraction_numerical': 0.0016638935108153079, 'mean_word_length': 3.50875, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 16}, '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': '212404', 'n_tokens_mistral': 1080, 'n_tokens_neox': 1047, 'n_words': 302}