<commit_before>/**
 * Collection to store fixture data.
 * @type {Mongo.Collection}
 */
var store = new Mongo.Collection('fixtures');

/**
 * Fixtures API
 * @type {Object}
 */
Fixtures = {

  /**
   * Returns an array of fixture `id` strings for a given `collection`.
   * @param {Mongo.Collection} collection Collection to get the `id` values of.
   * @return {Array.<String>} Array of fixture `id` strings.
   */
  ids: function(collection) {

    var cursor = store.find({
      collection: collection._name
    }, { fields: { id: 1 } });

    return Utils.pluck(cursor, 'id');

  },

  /**
   * Returns a document from the `collection` for the given `id`.
   * If no `id` is provided, returns a cursor to all fixture documents in the `collection`.
   * @param {Mongo.Collection} collection Collection to get the document from.
   * @param {String} id Unique identifier for the fixture document. Optional.
   * @return {Object} Document.
   */
  get: function(collection, id) {

    if (_.isString(id)) {

      var fixture = store.findOne({
        collection: collection._name, id: id
      }, { fields: { _id: 1 } });

      if (fixture) { return collection.findOne(fixture._id); }

    } else {

      var cursor = store.find({
        collection: collection._name
      }, { fields: { _id: 1 } });

      return collection.find({ _id: { $in: Utils.pluck(cursor, '_id') }});

    }

  },

  /**
   * Inserts a document into the `collection` for the given `id`,
   * passing it `data` and returns the new document `_id`.
   * @param {Mongo.Collection} collection Collection to insert the data into.
   * @param {String} id Unique identifier for the fixture document
   * @param {Object} data Data to insert into the collection.
   * @param {Function} proxy Function to call in place of `collection.insert`.
   * @return {String} Document `_id`.
   */
  insert: function(collection, id, data, proxy) {

    var doc = Fixtures.get(collection, id);

    if (!doc) {

      var _id = _.isFunction(proxy) ? proxy(data) :
                  collection.insert(data);

      if (_id) {

        store.insert({
          _id: _id, id: id, collection: collection._name
        });

        Counter.added(collection, 1);

        return id;

      }

    }
<commit_msg>Make Fixtures.insert return document _id<commit_after>/**
 * Collection to store fixture data.
 * @type {Mongo.Collection}
 */
var store = new Mongo.Collection('fixtures');

/**
 * Fixtures API
 * @type {Object}
 */
Fixtures = {

  /**
   * Returns an array of fixture `id` strings for a given `collection`.
   * @param {Mongo.Collection} collection Collection to get the `id` values of.
   * @return {Array.<String>} Array of fixture `id` strings.
   */
  ids: function(collection) {

    var cursor = store.find({
      collection: collection._name
    }, { fields: { id: 1 } });

    return Utils.pluck(cursor, 'id');

  },

  /**
   * Returns a document from the `collection` for the given `id`.
   * If no `id` is provided, returns a cursor to all fixture documents in the `collection`.
   * @param {Mongo.Collection} collection Collection to get the document from.
   * @param {String} id Unique identifier for the fixture document. Optional.
   * @return {Object} Document.
   */
  get: function(collection, id) {

    if (_.isString(id)) {

      var fixture = store.findOne({
        collection: collection._name, id: id
      }, { fields: { _id: 1 } });

      if (fixture) { return collection.findOne(fixture._id); }

    } else {

      var cursor = store.find({
        collection: collection._name
      }, { fields: { _id: 1 } });

      return collection.find({ _id: { $in: Utils.pluck(cursor, '_id') }});

    }

  },

  /**
   * Inserts a document into the `collection` for the given `id`,
   * passing it `data` and returns the new document `_id`.
   * @param {Mongo.Collection} collection Collection to insert the data into.
   * @param {String} id Unique identifier for the fixture document
   * @param {Object} data Data to insert into the collection.
   * @param {Function} proxy Function to call in place of `collection.insert`.
   * @return {String} Document `_id`.
   */
  insert: function(collection, id, data, proxy) {

    var doc = Fixtures.get(collection, id);

    if (!doc) {

      var _id = _.isFunction(proxy) ? proxy(data) :
                  collection.insert(data);

      if (_id) {

        store.insert({
          _id: _id, id: id, collection: collection._name
        });

        Counter.added(collection, 1);

        return _id;

      }

    }

{'fraction_non_alphanumeric': 0.13279192273924495, 'fraction_numerical': 0.001755926251097454, 'mean_word_length': 2.6514423076923075, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3159157', 'n_tokens_mistral': 1392, 'n_tokens_neox': 1327, 'n_words': 460}