<commit_before>var taskmanager = require('./taskmanager'),
    taskQueue = new taskmanager.TaskQueue(),
    path = require('path'),
    ExportJobList = require('./project').ExportJobList,
    Step = require('step');

module.exports = function(app, settings) {
    // Add Express route rule for serving export files for download.
    app.get('/export/download/*', function(req, res, next) {
        res.sendfile(
            path.join(settings.export_dir, req.params[0]),
            function(err, path) {
                return err && next(new Error('File not found.'));
            }
        );
    });

    // Loop for scanning and processing Exports.
    var scan = function() {
        Step(
            function() {
                var jobs = new ExportJobList();
                jobs.fetch({
                    success: this
                });
            },
            function(jobs) {
                jobs.each(function(job) {
                    if (job.get('status') === 'waiting') {
                        job.addTasks(taskQueue);
                    }
                });
                this();
            },
            function() {
                setTimeout(scan, 5000);
            }
        );
    }
    scan();
}<commit_msg>Don't scan for export tasks when testing.<commit_after>var taskmanager = require('./taskmanager'),
    path = require('path'),
    ExportJobList = require('./project').ExportJobList,
    Step = require('step');

module.exports = function(app, settings) {
    // Add Express route rule for serving export files for download.
    app.get('/export/download/*', function(req, res, next) {
        res.sendfile(
            path.join(settings.export_dir, req.params[0]),
            function(err, path) {
                return err && next(new Error('File not found.'));
            }
        );
    });

    // Loop for scanning and processing exports. Do not process exports if
    // testing -- otherwise, tests will never finish.
    // @TODO: Set up some other mechanism for testing exports.
    if (!process.env.NODE_ENV || process.env.NODE_ENV !== 'test') {
        var taskQueue = new taskmanager.TaskQueue();
        var scan = function() {
            Step(
                function() {
                    var jobs = new ExportJobList();
                    jobs.fetch({
                        success: this
                    });
                },
                function(jobs) {
                    jobs.each(function(job) {
                        if (job.get('status') === 'waiting') {
                            job.addTasks(taskQueue);
                        }
                    });
                    this();
                },
                function() {
                    setTimeout(scan, 5000);
                }
            );
        }
        scan();
    }
}
{'fraction_non_alphanumeric': 0.12583715192104336, 'fraction_numerical': 0.0035248501938667607, 'mean_word_length': 1.3454545454545455, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4761409', 'n_tokens_mistral': 727, 'n_tokens_neox': 677, 'n_words': 169}