<commit_before>// import {verifyToken} from 'jseminck-be-communication-utils';
import * as Translation from './../models/Translation';

/**
 * Request translations data from the API.
 */
async function get(req, res) {
    if (!req.query.language) res.status(500).send({error: "Please provide ?language= parameter"});

    try {
        const {language, limit} = req.query;
        const translations = await getTranslations(language, limit);
        return res.send(translations);
    } catch (err) {
        return res.status(500).send({'error': err});
    }
}

async function getTranslations(language, limit) {
    if (limit) {
        return await Translation.findAllForLanguageLimitBy(language, limit);
    }
    return await Translation.findAllForLanguage(language);
}

/**
 * Start a new game. Gets 20 random words from the database for a given language.
 */
async function startGame(req, res) {
    if (!req.query.language) res.status(500).send({error: "Please provide ?language= parameter"});

    try {
        const {language, limit} = req.query;
        const translations = await getTranslations(language, limit);
        return res.send(translations);
    } catch (err) {
        return res.status(500).send({'error': err});
    }
}

/**
 * Create a new translation.
 */
async function post(req, res) {
    try {
        let translation = await Translation.create(req.body);
        return res.status(200).send(translation);
    } catch (err) {
        return res.status(500).send({'error': err});
    }
}
<commit_msg>Use random words<commit_after>// import {verifyToken} from 'jseminck-be-communication-utils';
import * as Translation from './../models/Translation';

/**
 * Request translations data from the API.
 */
async function get(req, res) {
    if (!req.query.language) res.status(500).send({error: "Please provide ?language= parameter"});

    try {
        const {language, limit} = req.query;
        const translations = await getTranslations(language, limit);
        return res.send(translations);
    } catch (err) {
        return res.status(500).send({'error': err});
    }
}

async function getTranslations(language, limit) {
    if (limit) {
        return await Translation.findAllForLanguageLimitBy(language, limit);
    }
    return await Translation.findAllForLanguage(language);
}

/**
 * Start a new game. Gets 20 random words from the database for a given language.
 */
async function startGame(req, res) {
    if (!req.query.language) res.status(500).send({error: "Please provide ?language= parameter"});

    try {
        const {language} = req.query;
        const translations = await findRandomForLanguageLimitBy(language, 20);
        return res.send(translations);
    } catch (err) {
        return res.status(500).send({'error': err});
    }
}

/**
 * Create a new translation.
 */
async function post(req, res) {
    try {
        let translation = await Translation.create(req.body);
        return res.status(200).send(translation);
    } catch (err) {
        return res.status(500).send({'error': err});
    }
}

{'fraction_non_alphanumeric': 0.13852672750977835, 'fraction_numerical': 0.013689700130378096, 'mean_word_length': 3.181198910081744, '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': '7216399', 'n_tokens_mistral': 927, 'n_tokens_neox': 870, 'n_words': 241}