<commit_before>'use strict';

const db = requireDb();
const logger = require('elyoos-server-lib').logging.getLogger(__filename);

const getDetail = async function (userId, answerId) {

    let resp = await db.cypher().match("(c:Answer:Commitment {answerId: {answerId}})<-[:IS_ADMIN]-(user:User)")
        .optionalMatch(`(t:Topic)-[:TOPIC]->(c)`)
        .return(`c.title AS title, c.description AS description, c.website AS website, c.created AS created,
                 c.language AS language, EXISTS((:User {userId: {userId}})-[:IS_ADMIN]->(c)) AS isAdmin,
                 collect(t.name) AS topics`)
        .end({userId, answerId}).send();
    if (resp.length !== 1) {
        logger.warn(`Commitment with id ${answerId} not found`);
        throw new Error('404');
    }
    logger.info(`Get commitment with answerId ${answerId}`);
    return resp[0];
};

module.exports = {
    getDetail
};<commit_msg>Log improvement.<commit_after>'use strict';

const db = requireDb();
const logger = require('elyoos-server-lib').logging.getLogger(__filename);

const getDetail = async function (userId, answerId) {

    let resp = await db.cypher().match("(c:Answer:Commitment {answerId: {answerId}})<-[:IS_ADMIN]-(user:User)")
        .optionalMatch(`(t:Topic)-[:TOPIC]->(c)`)
        .return(`c.title AS title, c.description AS description, c.website AS website, c.created AS created,
                 c.language AS language, EXISTS((:User {userId: {userId}})-[:IS_ADMIN]->(c)) AS isAdmin,
                 collect(t.name) AS topics`)
        .end({userId, answerId}).send();
    if (resp.length !== 1) {
        logger.warn(`Commitment with id ${answerId} had ${resp.length} results`);
        throw new Error('404');
    }
    logger.info(`Get commitment with answerId ${answerId}`);
    return resp[0];
};

module.exports = {
    getDetail
};
{'fraction_non_alphanumeric': 0.1742671009771987, 'fraction_numerical': 0.0054288816503800215, 'mean_word_length': 3.419664268585132, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '2873539', 'n_tokens_mistral': 579, 'n_tokens_neox': 576, 'n_words': 136}