<commit_before>'use strict';

const joi = require('joi');

const countSchema = joi
    .object()
    .options({ stripUnknown: true })
    .keys({
        yes: joi
            .number()
            .min(0)
            .default(0),
        no: joi
            .number()
            .min(0)
            .default(0),
        variants: joi.object({
            arg: joi.string(),
            value: joi.number().min(0),
        }),
    });

const clientMetricsSchema = joi
    .object()
    .options({ stripUnknown: true })
    .keys({
        appName: joi.string().required(),
        instanceId: joi.string().required(),
        bucket: joi
            .object()
            .required()
            .keys({
                start: joi.date().required(),
                stop: joi.date().required(),
                toggles: joi.object().pattern(/.*/, countSchema),
            }),
    });

module.exports = { clientMetricsSchema };
<commit_msg>fix: metric-schema for variant counts<commit_after>'use strict';

const joi = require('joi');

const countSchema = joi
    .object()
    .options({ stripUnknown: true })
    .keys({
        yes: joi
            .number()
            .min(0)
            .default(0),
        no: joi
            .number()
            .min(0)
            .default(0),
        variants: joi.object().pattern(joi.string(), joi.number().min(0)),
    });

const clientMetricsSchema = joi
    .object()
    .options({ stripUnknown: true })
    .keys({
        appName: joi.string().required(),
        instanceId: joi.string().required(),
        bucket: joi
            .object()
            .required()
            .keys({
                start: joi.date().required(),
                stop: joi.date().required(),
                toggles: joi.object().pattern(/.*/, countSchema),
            }),
    });

module.exports = { clientMetricsSchema };

{'fraction_non_alphanumeric': 0.15978552278820377, 'fraction_numerical': 0.005361930294906166, 'mean_word_length': 1.5250338294993233, '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': '917834', 'n_tokens_mistral': 545, 'n_tokens_neox': 538, 'n_words': 111}