<commit_before>import shortid from 'shortid';

export default function Image(img = {}) {
  this.name = img.name || '';
  this.file = img.file || null;
  this.url = img.url || null;
  this.shortid = img.shortid || shortid.generate();
  this.state = img.state || 0;
  this.progress = img.progress || 0;
  this.ratio = img.ratio || 0.75;

  // Methods
  this.getUrl = () => {
    const url = this.file
      ? window.URL.createObjectURL(this.file)
      : this.url || null;
    return url;
  };

  this.getSmallestThumbUrl = () => {
    if (this.thumbnails && Object.keys(this.thumbnails)) {
      return this.thumbnails[Math.min.apply(null, Object.keys(this.thumbnails))];
    }
    return this.getUrl();
  }

  this.getBiggestThumbUrl = () => {
    if (this.thumbnails && Object.keys(this.thumbnails)) {
      return this.thumbnails[Math.max.apply(null, Object.keys(this.thumbnails))];
    }
    return this.getUrl();
  }

  this.getSrcSetString = () => {<commit_msg>Use _id in model, but don't set it for new images<commit_after>import shortid from 'shortid';

export default function Image(img = {}) {
  this._id = img._id || undefined;
  this.file = img.file || null;
  this.url = img.url || null;
  this.shortid = img.shortid || shortid.generate();
  this.state = img.state || 0;
  this.progress = img.progress || 0;
  this.ratio = img.ratio || 0.75;

  // Methods
  this.getUrl = () => {
    const url = this.file
      ? window.URL.createObjectURL(this.file)
      : this.url || null;
    return url;
  };

  this.getSmallestThumbUrl = () => {
    if (this.thumbnails && Object.keys(this.thumbnails)) {
      return this.thumbnails[Math.min.apply(null, Object.keys(this.thumbnails))];
    }
    return this.getUrl();
  }

  this.getBiggestThumbUrl = () => {
    if (this.thumbnails && Object.keys(this.thumbnails)) {
      return this.thumbnails[Math.max.apply(null, Object.keys(this.thumbnails))];
    }
    return this.getUrl();
  }

  this.getSrcSetString = () => {
{'fraction_non_alphanumeric': 0.16624429802331475, 'fraction_numerical': 0.00506842372022301, 'mean_word_length': 3.020366598778004, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '4850740', 'n_tokens_mistral': 708, 'n_tokens_neox': 690, 'n_words': 125}