<commit_before>
var dcopy = require('deep-copy');
// listview
var listview = {
    query: require('../lib/listview/query'),
    data: require('../lib/listview/data')},
    pagination = require('../lib/listview/pagination'),
    filter = require('../lib/listview/filter');
// editview
var editview = {
    otm: require('../lib/editview/data').otm,
    stc: require('../lib/editview/data').stc,
    format: require('../lib/editview/format')
};


function getArgs (req, res) {
    var args = {
        settings : res.locals._admin.settings,
        db       : res.locals._admin.db,
        debug    : res.locals._admin.debug,
        log      : res.locals._admin.log,
        slug     : req.params[0],
        page     : req.query.p || 0,
        data     : req.body
    };
    args.name = res.locals._admin.slugs[args.slug];
    args.config = dcopy(args.settings[args.name]);
    return args;
}

exports.get = function (req, res, next) {
    data(req, res, next);
}

exports.post = function (req, res, next) {
    data(req, res, next);
}

function data (req, res, next) {
    var args = getArgs(req, res),
        events = res.locals._admin.events;

    args.filter = filter.prepareSession(req, args);
    listview.query(args);

    events.preList(req, res, args, function () {
    listview.data(args, function (err, data) {
        if (err) return next(err);
        pagination.get(args, function (err, pager) {
            if (err) return next(err);
            // always should be in front of filter.getColumns
            // as it may reduce args.config.columns
            var order = filter.getOrderColumns(req, args);
            args.config.columns = filter.getColumns(args);

            editview.otm.get(args, function (err) {
                if (err) return next(err);
                editview.stc.get(args);

                render(req, res, args, data, pager, order, next);
            });
        });
    });
    });
}

function render (req, res, args, data, pager, order, next) {
    // set filter active items
    for (var i=0; i < args.config.columns.length; i++) {
        var column = args.config.columns[i],
            value = args.filter.columns[column.name];
        column.value = editview.format.value(column, value);
    }

    res.locals.view = {
        name: args.config.table.verbose,
        slug: args.slug,
        error: res.locals.error
    };<commit_msg>Filter columns have defaultValue set to null<commit_after>
var dcopy = require('deep-copy');
// listview
var listview = {
    query: require('../lib/listview/query'),
    data: require('../lib/listview/data')},
    pagination = require('../lib/listview/pagination'),
    filter = require('../lib/listview/filter');
// editview
var editview = {
    otm: require('../lib/editview/data').otm,
    stc: require('../lib/editview/data').stc,
    format: require('../lib/editview/format')
};


function getArgs (req, res) {
    var args = {
        settings : res.locals._admin.settings,
        db       : res.locals._admin.db,
        debug    : res.locals._admin.debug,
        log      : res.locals._admin.log,
        slug     : req.params[0],
        page     : req.query.p || 0,
        data     : req.body
    };
    args.name = res.locals._admin.slugs[args.slug];
    args.config = dcopy(args.settings[args.name]);
    return args;
}

exports.get = function (req, res, next) {
    data(req, res, next);
}

exports.post = function (req, res, next) {
    data(req, res, next);
}

function data (req, res, next) {
    var args = getArgs(req, res),
        events = res.locals._admin.events;

    args.filter = filter.prepareSession(req, args);
    listview.query(args);

    events.preList(req, res, args, function () {
    listview.data(args, function (err, data) {
        if (err) return next(err);
        pagination.get(args, function (err, pager) {
            if (err) return next(err);
            // always should be in front of filter.getColumns
            // as it may reduce args.config.columns
            var order = filter.getOrderColumns(req, args);
            args.config.columns = filter.getColumns(args);

            editview.otm.get(args, function (err) {
                if (err) return next(err);
                editview.stc.get(args);

                render(req, res, args, data, pager, order, next);
            });
        });
    });
    });
}

function render (req, res, args, data, pager, order, next) {
    // set filter active items
    for (var i=0; i < args.config.columns.length; i++) {
        var column = args.config.columns[i],
            value = args.filter.columns[column.name];
        column.defaultValue = null;
        column.value = editview.format.value(column, value);
    }

    res.locals.view = {
        name: args.config.table.verbose,
        slug: args.slug,
        error: res.locals.error
    };
{'fraction_non_alphanumeric': 0.15135246747883543, 'fraction_numerical': 0.0012389015073301672, 'mean_word_length': 2.172233136869679, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6494915', 'n_tokens_mistral': 1551, 'n_tokens_neox': 1534, 'n_words': 346}