<commit_before>import Ember from 'ember';
import ApplicationSerializer from './application';

const { get, assign } = Ember;

export default ApplicationSerializer.extend({
  attrs: {
    parameterized: 'ParameterizedJob',
  },

  normalize(typeHash, hash) {
    // Transform the map-based JobSummary object into an array-based
    // JobSummary fragment list
    hash.TaskGroupSummaries = Object.keys(get(hash, 'JobSummary.Summary')).map(key => {
      const allocStats = get(hash, `JobSummary.Summary.${key}`);
      const summary = { Name: key };

      Object.keys(allocStats).forEach(
        allocKey => (summary[`${allocKey}Allocs`] = allocStats[allocKey])
      );

      return summary;
    });

    // Lift the children stats out of the JobSummary object
    const childrenStats = get(hash, 'JobSummary.Children');
    if (childrenStats) {
      Object.keys(childrenStats).forEach(
        childrenKey => (hash[`${childrenKey}Children`] = childrenStats[childrenKey])
      );
    }

    return this._super(typeHash, hash);
  },

  extractRelationships(modelClass, hash) {
    const { modelName } = modelClass;
    const jobURL = this.store
      .adapterFor(modelName)
      .buildURL(modelName, this.extractId(modelClass, hash), hash, 'findRecord');

    return assign(this._super(...arguments), {
      allocations: {
        links: {
          related: `${jobURL}/allocations`,
        },
      },
      versions: {
        links: {
          related: `${jobURL}/versions?diffs=true`,
        },
      },
      deployments: {
        links: {
          related: `${jobURL}/deployments`,
        },
      },
    });
  },
});<commit_msg>Make sure to include the namespace qp on all job related resources<commit_after>import Ember from 'ember';
import ApplicationSerializer from './application';
import queryString from 'npm:query-string';

const { get, assign } = Ember;

export default ApplicationSerializer.extend({
  attrs: {
    parameterized: 'ParameterizedJob',
  },

  normalize(typeHash, hash) {
    hash.NamespaceID = hash.Namespace;

    // Transform the map-based JobSummary object into an array-based
    // JobSummary fragment list
    hash.TaskGroupSummaries = Object.keys(get(hash, 'JobSummary.Summary')).map(key => {
      const allocStats = get(hash, `JobSummary.Summary.${key}`);
      const summary = { Name: key };

      Object.keys(allocStats).forEach(
        allocKey => (summary[`${allocKey}Allocs`] = allocStats[allocKey])
      );

      return summary;
    });

    // Lift the children stats out of the JobSummary object
    const childrenStats = get(hash, 'JobSummary.Children');
    if (childrenStats) {
      Object.keys(childrenStats).forEach(
        childrenKey => (hash[`${childrenKey}Children`] = childrenStats[childrenKey])
      );
    }

    return this._super(typeHash, hash);
  },

  extractRelationships(modelClass, hash) {
    const namespace =
      !hash.NamespaceID || hash.NamespaceID === 'default' ? undefined : hash.NamespaceID;
    const { modelName } = modelClass;
    const jobURL = this.store
      .adapterFor(modelName)
      .buildURL(modelName, this.extractId(modelClass, hash), hash, 'findRecord');

    return assign(this._super(...arguments), {
      allocations: {
        links: {
          related: buildURL(`${jobURL}/allocations`, { namespace: namespace }),
        },
      },
      versions: {
        links: {
          related: buildURL(`${jobURL}/versions`, { namespace: namespace, diffs: true }),
        },
      },
      deployments: {
        links: {
          related: buildURL(`${jobURL}/deployments`, { namespace: namespace }),
        },
      },
    });
  },
});

function buildURL(path, queryParams) {
  const qpString = queryString.stringify(queryParams);
  if (qpString) {
    return `${path}?${qpString}`;
  }
  return path;
}
{'fraction_non_alphanumeric': 0.13792200994504056, 'fraction_numerical': 0.0, 'mean_word_length': 2.9119754350051177, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '7118312', 'n_tokens_mistral': 1104, 'n_tokens_neox': 1092, 'n_words': 240}