<commit_before>'use strict';

const linz = require('../../../../');
const cellRenderers = require('./');
const utils = require('../../../utils');

const defaultRenderer = (val, record, fieldName, model, callback) => {
    if (val === undefined) {
        return callback(null);
    }

    if (Array.isArray(val)) {
        if (!val.length) {
            return callback(null);
        }

        // check if this field is a document array
        if (Array.isArray(model.schema.tree[fieldName])) {
            return cellRenderers.documentArray(
                val,
                record,
                fieldName,
                model,
                callback
            );
        }

        return cellRenderers.array(val, record, fieldName, model, callback);
    }

    if (val instanceof Date) {
        return cellRenderers.date(val, record, fieldName, model, callback);
    }

    if (val !== '' && utils.isBoolean(val)) {
        return cellRenderers.boolean(val, record, fieldName, model, callback);
    }

    console.log('teh val', val);

    // check if field is a reference document
    if (
        model.schema.tree[fieldName] &&
        model.schema.tree[fieldName].ref &&
        linz.api.model.getObjectIdFromRefField(val) instanceof
            linz.mongoose.Types.ObjectId
    ) {
        return cellRenderers.referenceName(
            val,
            record,
            fieldName,
            model,
            callback
        );
    }

    return callback(null, val);
};

module.exports = defaultRenderer;<commit_msg>remove comment<commit_after>'use strict';

const linz = require('../../../../');
const cellRenderers = require('./');
const utils = require('../../../utils');

const defaultRenderer = (val, record, fieldName, model, callback) => {
    if (val === undefined) {
        return callback(null);
    }

    if (Array.isArray(val)) {
        if (!val.length) {
            return callback(null);
        }

        // check if this field is a document array
        if (Array.isArray(model.schema.tree[fieldName])) {
            return cellRenderers.documentArray(
                val,
                record,
                fieldName,
                model,
                callback
            );
        }

        return cellRenderers.array(val, record, fieldName, model, callback);
    }

    if (val instanceof Date) {
        return cellRenderers.date(val, record, fieldName, model, callback);
    }

    if (val !== '' && utils.isBoolean(val)) {
        return cellRenderers.boolean(val, record, fieldName, model, callback);
    }

    // check if field is a reference document
    if (
        model.schema.tree &&
        model.schema.tree[fieldName] &&
        model.schema.tree[fieldName].ref &&
        linz.api.model.getObjectIdFromRefField(val) instanceof
            linz.mongoose.Types.ObjectId
    ) {
        return cellRenderers.referenceName(
            val,
            record,
            fieldName,
            model,
            callback
        );
    }

    return callback(null, val);
};

module.exports = defaultRenderer;
{'fraction_non_alphanumeric': 0.1262919896640827, 'fraction_numerical': 0.0, 'mean_word_length': 1.8027149321266969, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1198522', 'n_tokens_mistral': 845, 'n_tokens_neox': 840, 'n_words': 196}