<commit_before>'use strict';
var _ = require('lodash');
var P = require('bluebird');
var humps = require('humps');
var Schemas = require('../generators/schemas');

function ResourceDeserializer(model, params) {
  var schema = Schemas.schemas[model.collection.name];

  function extractAttributes() {
    return new P(function (resolve) {
      var attributes = params.data.attributes;
      attributes._id = params.data.id;
      resolve(attributes);
    });
  }

  function extractRelationships() {
    return new P(function (resolve) {
      var relationships = {};

      _.each(schema.fields, function (field) {
        if (field.reference && params.data.relationships[field.field]) {
          relationships[field.field] = params.data.relationships[field.field]
            .data.id;
        }
      });

      resolve(relationships);
    });
  }

  this.perform = function () {
    return P.all([extractAttributes(), extractRelationships()])
      .spread(function (attributes, relationships) {
        return humps.camelizeKeys(_.extend(attributes, relationships));
      });
  };
}

module.exports = ResourceDeserializer;<commit_msg>Fix de deserializer for data: null<commit_after>'use strict';
var _ = require('lodash');
var P = require('bluebird');
var humps = require('humps');
var Schemas = require('../generators/schemas');

function ResourceDeserializer(model, params) {
  var schema = Schemas.schemas[model.collection.name];

  function extractAttributes() {
    return new P(function (resolve) {
      var attributes = params.data.attributes;
      attributes._id = params.data.id;
      resolve(attributes);
    });
  }

  function extractRelationships() {
    return new P(function (resolve) {
      var relationships = {};

      _.each(schema.fields, function (field) {
        if (field.reference && params.data.relationships[field.field] &&
          params.data.relationships[field.field].data) {
          relationships[field.field] = params.data.relationships[field.field]
            .data.id;
        }
      });

      resolve(relationships);
    });
  }

  this.perform = function () {
    return P.all([extractAttributes(), extractRelationships()])
      .spread(function (attributes, relationships) {
        return humps.camelizeKeys(_.extend(attributes, relationships));
      });
  };
}

module.exports = ResourceDeserializer;
{'fraction_non_alphanumeric': 0.13771186440677965, 'fraction_numerical': 0.0, 'mean_word_length': 3.277173913043478, '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': '2327582', 'n_tokens_mistral': 678, 'n_tokens_neox': 653, 'n_words': 129}