<commit_before>var promises = {};

var Repository = {
  find: function (id, accessToken) {
    var promise = promises[id];

    if (promise) {
      return promise;
    }

    promise = new Ember.RSVP.Promise(function(resolve, reject) {
      function success(json) {
        Ember.run(null, resolve, json);
      }

      function error(jqXHR, textStatus, errorThrown) {
        delete promises[id];
        Ember.run(null, reject, jqXHR);
      }

      Ember.$.ajax({
        type: 'get',
        url: 'https://api.github.com/repos/' + id,
        dataType: 'json',
        beforeSend: function(xhr){
          if (accessToken) {
            xhr.setRequestHeader('Authorization', "token " + accessToken);
          }
        },
        success: success,
        error: error
      });
    });

    promises[id] = promise;

    return promise;
  }
};

export default Repository;<commit_msg>use the shared run-loop aware ajax util<commit_after>import ajax from 'glazier/utils/ajax';

var promises = {};
var Repository = {
  find: function (id, accessToken) {
    var promise = promises[id];

    if (promise) {
      return promise;
    }

    promise = ajax('https://api.github.com/repos/' + id, {
      type: 'get',
      dataType: 'json',
      beforeSend: function(xhr) {
        if (accessToken) {
          xhr.setRequestHeader('Authorization', "token " + accessToken);
        }
      }
    });

    promises[id] = promise;

    return promise;
  }
};

export default Repository;
{'fraction_non_alphanumeric': 0.1351714862138534, 'fraction_numerical': 0.0, 'mean_word_length': 2.227765726681128, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '3185218', 'n_tokens_mistral': 470, 'n_tokens_neox': 458, 'n_words': 104}