<commit_before>from odk_viewer.models import ParsedInstance


def get_form_submissions_per_day(xform):
    """Number of submissions per day for the form."""
    query = {}
    query[ParsedInstance.USERFORM_ID] =\
        u'%s_%s' % (xform.user.username, xform.id_string)
    pipeline = [
        {
            "$group": {
                "_id": {
                    "$substr": ['$_submission_time', 0, 10]
                },
                "count": {"$sum": 1}
            }
        },
        {
            "$sort": {"_id": 1}
        },
        {
            "$project": {
                "date": "$_id",
                "count": 1
            }
        }
    ]
    kargs = {
        'query': query,
        'pipeline': pipeline
    }
    return ParsedInstance.mongo_aggregate(**kargs)<commit_msg>UK: use api function for submission stats<commit_after>from api.tools import get_form_submissions_grouped_by_field


def get_form_submissions_per_day(xform):
    """Number of submissions per day for the form."""
    return get_form_submissions_grouped_by_field(xform, '_submission_time',
                                                 'date')
{'fraction_non_alphanumeric': 0.12139737991266375, 'fraction_numerical': 0.005240174672489083, 'mean_word_length': 1.7028301886792452, 'pattern_counts': {'":': 10, '<': 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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7436661', 'n_tokens_mistral': 353, 'n_tokens_neox': 336, 'n_words': 67}