<commit_before>const mongoose = require('mongoose');
const Producer = mongoose.model('Producer');
const Record = mongoose.model('ConsolidatedRecord');

exports.list = function (req, res, next) {
    Producer
        .find()
        .lean()
        .exec(function (err, producers) {
            if (err) return next(err);
            res.send(producers);
        });
};

exports.fetch = function (req, res, next, id) {
    Producer.findById(id, function (err, producer) {
        if (err) return next(err);
        if (!producer) return res.sendStatus(404);
        req.producer = producer;
        next();
    });
};

exports.associate = function (req, res, next) {
    Producer.create({ _id: req.body._id, associatedTo: req.organization._id }, function (err, producer) {
        if (err) return next(err);
        res.send(producer);
    });
};

exports.dissociate = function (req, res, next) {
    if (!req.producer.associatedTo.equals(req.organization._id)) return res.sendStatus(404);
    Producer.findByIdAndRemove(req.producer._id, function (err) {
        if (err) return next(err);
        res.sendStatus(200);
    });
};

const facetEligibilityCondition = { $all: [<commit_msg>Ensure producer dissociation return 204<commit_after>const mongoose = require('mongoose');
const Producer = mongoose.model('Producer');
const Record = mongoose.model('ConsolidatedRecord');

exports.list = function (req, res, next) {
    Producer
        .find()
        .lean()
        .exec(function (err, producers) {
            if (err) return next(err);
            res.send(producers);
        });
};

exports.fetch = function (req, res, next, id) {
    Producer.findById(id, function (err, producer) {
        if (err) return next(err);
        if (!producer) return res.sendStatus(404);
        req.producer = producer;
        next();
    });
};

exports.associate = function (req, res, next) {
    Producer.create({ _id: req.body._id, associatedTo: req.organization._id }, function (err, producer) {
        if (err) return next(err);
        res.send(producer);
    });
};

exports.dissociate = function (req, res, next) {
    if (!req.producer.associatedTo.equals(req.organization._id)) return res.sendStatus(404);
    Producer.findByIdAndRemove(req.producer._id, function (err) {
        if (err) return next(err);
        res.status(204).end();
    });
};

const facetEligibilityCondition = { $all: [
{'fraction_non_alphanumeric': 0.15041666666666667, 'fraction_numerical': 0.00875, 'mean_word_length': 3.0016666666666665, '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': '2644949', 'n_tokens_mistral': 770, 'n_tokens_neox': 748, 'n_words': 172}