<commit_before>module.exports = function(makeEndpoint) {
  var MakeAPI = require('makeapi'),
      make;

  make = MakeAPI({
    makeAPI: makeEndpoint
  });

  /**
   * db function object that we return
   */
  var makeAPI = {

    /**
     * Create a make if no duplicates exist under this user,
     * otherwise update the duplicate.
     */
    publish: function(data, callback) {
      makeAPI.search(data, function(err, results) {
        if (err) {
          callback(err, results);
        } else if (results.length) {
          make.update(results[0]._id, data, function(results, err) {
            callback(err, results);
          });
        } else {
          make.create(data, function(results, err) {
            callback(err, results);
          });
        }
      });
    },

    /**
     * Find makes by search criteria.
     */
    search: function(data, callback) {
      if (data.url) {
        make.find({url: data.url}).email(data.email).then( function( result ) {
          callback( result.error, result.hits );
        });
      } else {
        make.email(data.email).limit(100).then( function( result ) {
          callback( result.error, result.hits );
        });
      }
    },
<commit_msg>[#861816] Reversed error order because of update in the make api.<commit_after>module.exports = function(makeEndpoint) {
  var MakeAPI = require('makeapi'),
      make;

  make = MakeAPI({
    makeAPI: makeEndpoint
  });

  /**
   * db function object that we return
   */
  var makeAPI = {

    /**
     * Create a make if no duplicates exist under this user,
     * otherwise update the duplicate.
     */
    publish: function(data, callback) {
      makeAPI.search(data, function(err, results) {
        if (err) {
          callback(err, results);
        } else if (results.length) {
          make.update(results[0]._id, data, callback);
        } else {
          make.create(data, callback);
        }
      });
    },

    /**
     * Find makes by search criteria.
     */
    search: function(data, callback) {
      if (data.url) {
        make.find({url: data.url}).email(data.email).then( function( err, result ) {
          callback( err, result.hits );
        });
      } else {
        make.email(data.email).limit(100).then( function( err, result ) {
          callback( err, result.hits );
        });
      }
    },

{'fraction_non_alphanumeric': 0.13825275657336725, 'fraction_numerical': 0.005937234944868533, 'mean_word_length': 1.94875, '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': '6460267', 'n_tokens_mistral': 707, 'n_tokens_neox': 685, 'n_words': 168}