<commit_before>// An UploadDocument is an in-progress file upload, currently waiting in the queue.
dc.model.UploadDocument = Backbone.Model.extend({

  FILE_EXTENSION_MATCHER : /\.([^.]+)$/,

  MAX_FILE_SIZE : 419430400, // 400 Megabytes

  defaults: {
    complete: false
  },

  // When creating an UploadDocument, we pull off some properties that
  // are on the file object, and attach them as attributes.
  set : function(attrs) {
    var file = attrs.file;
    if (file) {
      var fileName    = file.fileName || file.name;
      fileName        = fileName.match(/[^\/\\]+$/)[0]; // C:\fakepath\yatta yatta.pdf => yatta yatta.pdf
      attrs.title     = dc.inflector.titleize(fileName.replace(this.FILE_EXTENSION_MATCHER, ''));
      var extMatch    = fileName.match(this.FILE_EXTENSION_MATCHER);
      attrs.extension = extMatch && extMatch[1];
      attrs.size      = file.fileSize || file.size || null;
    }
    Backbone.Model.prototype.set.call(this, attrs);
    return this;
  },

  overSizeLimit : function() {
    return this.get('size') >= this.MAX_FILE_SIZE;
  },

  abort: function(){
    if ( this.get('data').processing() ){
      this.get('data').abort();
    }
  }

});

// The set of UploadDocuments is ordered by the position in which they were added.
dc.model.UploadDocumentSet = Backbone.Collection.extend({

  model : dc.model.UploadDocument,

  comparator : function(model) {
    return model.get('position');
  },

  // returns an array of all completed uploads
  completed: function(){
    return this.where({complete: true});
  }
});

window.UploadDocuments = new dc.model.UploadDocumentSet();
<commit_msg>Use 'pending' state to check for upload status<commit_after>// An UploadDocument is an in-progress file upload, currently waiting in the queue.
dc.model.UploadDocument = Backbone.Model.extend({

  FILE_EXTENSION_MATCHER : /\.([^.]+)$/,

  MAX_FILE_SIZE : 419430400, // 400 Megabytes

  defaults: {
    complete: false
  },

  // When creating an UploadDocument, we pull off some properties that
  // are on the file object, and attach them as attributes.
  set : function(attrs) {
    var file = attrs.file;
    if (file) {
      var fileName    = file.fileName || file.name;
      fileName        = fileName.match(/[^\/\\]+$/)[0]; // C:\fakepath\yatta yatta.pdf => yatta yatta.pdf
      attrs.title     = dc.inflector.titleize(fileName.replace(this.FILE_EXTENSION_MATCHER, ''));
      var extMatch    = fileName.match(this.FILE_EXTENSION_MATCHER);
      attrs.extension = extMatch && extMatch[1];
      attrs.size      = file.fileSize || file.size || null;
    }
    Backbone.Model.prototype.set.call(this, attrs);
    return this;
  },

  overSizeLimit : function() {
    return this.get('size') >= this.MAX_FILE_SIZE;
  },

  // aborts the file upload if it still in progress
  abort: function(){
    var upload = this.get('data');
    if ( upload && 'pending' == upload.state() ){
      upload.abort();
    }
  }

});

// The set of UploadDocuments is ordered by the position in which they were added.
dc.model.UploadDocumentSet = Backbone.Collection.extend({

  model : dc.model.UploadDocument,

  comparator : function(model) {
    return model.get('position');
  },

  // returns an array of all completed uploads
  completed: function(){
    return this.where({complete: true});
  }
});

window.UploadDocuments = new dc.model.UploadDocumentSet();

{'fraction_non_alphanumeric': 0.13767688679245282, 'fraction_numerical': 0.008254716981132075, 'mean_word_length': 3.083032490974729, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '6977171', 'n_tokens_mistral': 1082, 'n_tokens_neox': 1053, 'n_words': 267}