<commit_before>Travis.Record = SC.Record.extend({
  childRecordNamespace: Travis,
  primaryKey: 'id',
  id: SC.Record.attr(Number),

  update: function(attrs) {
    this.whenReady(function(record) {
      // TODO should not need to camelize here, should we? otherwise bindings seem to get stuck.
      $.each(attrs, function(key, value) {
        if(key != 'id' && key != 'status') record.set($.camelize(key, false), value);
      });
    });
    return this;
  },

  whenReady: function(callback) {
    if(!callback) {
      return this;
    } else if(this.get('status') & SC.Record.READY) {
      callback(this);
    } else {
      this.addObserver('status', function() {
        if(this.get('status') & SC.Record.READY) { callback(this); }
      })
    }
    return this;
  }
});

Travis.Record.reopenClass({
  exists: function(id) {
    if(id === undefined) throw('id is undefined');
    return Travis.store.storeKeyExists(this, id);
  },

  createOrUpdate: function(attrs) {
    if(this.exists(attrs.id)) {
      return this.update(attrs);
    } else {
      return Travis.store.createRecord(this, attrs);
    }
  },

  update: function(attrs) {
    if(attrs.id === undefined) throw('id is undefined');
    var record = this.find(attrs.id);
    return record.update(attrs);
  },

  find: function(id, callback) {
    if(id === undefined) throw('id is undefined');
    var record = Travis.store.find(this, id)
    return record ? record.whenReady(callback) : record;
  },

  all: function(options, mode) {
    return Travis.store.find(Travis.Query.cached(this, options || {}, mode));
  },
});
<commit_msg>temporarily don't use an observer here, not sure what to do in this case, yet<commit_after>Travis.Record = SC.Record.extend({
  childRecordNamespace: Travis,
  primaryKey: 'id',
  id: SC.Record.attr(Number),

  update: function(attrs) {
    this.whenReady(function(record) {
      // TODO should not need to camelize here, should we? otherwise bindings seem to get stuck.
      $.each(attrs, function(key, value) {
        if(key != 'id' && key != 'status') record.set($.camelize(key, false), value);
      });
    });
    return this;
  },

  whenReady: function(callback) {
    if(!callback) {
      return this;
    } else if(this.get('status') & SC.Record.READY) {
      callback(this);
    } else {
      // this.addObserver('status', function() {
      //   if(this.get('status') & SC.Record.READY) { callback(this); }
      // })
    }
    return this;
  }
});

Travis.Record.reopenClass({
  exists: function(id) {
    if(id === undefined) throw('id is undefined');
    return Travis.store.storeKeyExists(this, id);
  },

  createOrUpdate: function(attrs) {
    if(this.exists(attrs.id)) {
      return this.update(attrs);
    } else {
      return Travis.store.createRecord(this, attrs);
    }
  },

  update: function(attrs) {
    if(attrs.id === undefined) throw('id is undefined');
    var record = this.find(attrs.id);
    return record.update(attrs);
  },

  find: function(id, callback) {
    if(id === undefined) throw('id is undefined');
    var record = Travis.store.find(this, id)
    return record ? record.whenReady(callback) : record;
  },

  all: function(options, mode) {
    return Travis.store.find(Travis.Query.cached(this, options || {}, mode));
  },
});

{'fraction_non_alphanumeric': 0.16317228805834094, 'fraction_numerical': 0.0, 'mean_word_length': 3.0945273631840795, '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': '122172', 'n_tokens_mistral': 1075, 'n_tokens_neox': 1055, 'n_words': 234}