<commit_before>import DS from 'ember-data';

export default DS.RESTSerializer.extend({
  normalizePayload(payload) {
    this._super.apply(this, arguments);

    delete payload.ok;

    return payload;
  },

  modelNameFromPayloadKey: function(key) {
    if (key === 'members') {
      return 'user';
    }

    return this._super.apply(this, arguments);
  },

  keyForAttribute: function(attr, method) {
    return Ember.String.underscore(attr);
  }
});<commit_msg>Serializer should flatten user profile attrs<commit_after>import DS from 'ember-data';

export default DS.RESTSerializer.extend({
  normalizePayload(payload) {
    this._super.apply(this, arguments);

    delete payload.ok;

    return payload;
  },

  modelNameFromPayloadKey(key) {
    if (key === 'members') {
      return 'user';
    }

    return this._super.apply(this, arguments);
  },

  keyForAttribute(attr, method) {
    return Ember.String.underscore(attr);
  },

  _normalizeUserProfile(hash) {
    if (typeof hash.profile !== 'object') {
      return;
    }

    // Merge profile into attribute hash
    for (var key in hash.profile) {
      hash[key] = hash.profile[key];
    }

    delete hash.profile;
  },

  normalize(typeClass, hash, prop) {
    if (typeClass.modelName === 'user') {
      this._normalizeUserProfile(hash);
    }

    return this._super.apply(this, arguments);
  }
});
{'fraction_non_alphanumeric': 0.13347921225382933, 'fraction_numerical': 0.0, 'mean_word_length': 3.2215384615384615, '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': '1647040', 'n_tokens_mistral': 441, 'n_tokens_neox': 422, 'n_words': 91}