<commit_before>"use strict";

module.exports = jsonTransformPlugin;

function jsonTransformPlugin(schema) {
  schema.set('toJSON', {transform: fixDates});
  schema.set('toObject', {transform: fixDates});
}

function fixDates(doc, ret, options) {
  ['start_date', 'end_date', 'birth_date', 'death_date', 'founding_date', 'dissolution_date'].forEach(function(field) {
    if (!ret[field]) {
      ret[field] = null;
    }

  });
  return ret;
}<commit_msg>Make sure translations are applied when converting to JSON<commit_after>"use strict";

module.exports = jsonTransformPlugin;

function jsonTransformPlugin(schema) {
  schema.set('toJSON', {transform: fixDates, getters: true});
  schema.set('toObject', {transform: fixDates, getters: true});
}

function fixDates(doc, ret, options) {
  ['start_date', 'end_date', 'birth_date', 'death_date', 'founding_date', 'dissolution_date'].forEach(function(field) {
    if (!ret[field]) {
      ret[field] = null;
    }

  });
  return ret;
}
{'fraction_non_alphanumeric': 0.16276703967446593, 'fraction_numerical': 0.0, 'mean_word_length': 5.516556291390729, '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': '5802478', 'n_tokens_mistral': 331, 'n_tokens_neox': 319, 'n_words': 68}