<commit_before>Schema = mongoose.Schema
ObjectId = Schema.ObjectId

Comment = new Schema {
  body      : String,
  author_id : ObjectId,
  date      : Date
}

File = new Schema {
  path  : String,
  size  : Number
}

Torrent = new Schema {
  uploader     : String,
  title        : String,
  size         : Number,
  dateUploaded : {type: Date, default: new Date},
  files        : [File],
  description  : String,
  comments     : [Comment],
  category     : String,
  infohash     : {type: String, index: {unique:true}}
  permalink    : {type: String, index: {unique:true}}
}

Torrent.method 'generatePermalink', (callback) ->
<<<<<<< HEAD
  re = new RegExp(' ', 'g')
  baseurl = @title.substring(0, 75).replace(re, '_')
  # check for collisions
  checkFunc = (base, endno) =>
    if endno > 0
      url = base + '-' + endno
    else
      url = base
    (mongoose.model 'Torrent').findOne {'permalink' : url}, (err, doc) =>
      if doc
        checkFunc base, endno+1
      else
        @permalink = url<commit_msg>less verbosity on whitespace regexp<commit_after>Schema = mongoose.Schema
ObjectId = Schema.ObjectId

Comment = new Schema {
  body      : String,
  author_id : ObjectId,
  date      : Date
}

File = new Schema {
  path  : String,
  size  : Number
}

Torrent = new Schema {
  uploader     : String,
  title        : String,
  size         : Number,
  dateUploaded : {type: Date, default: new Date},
  files        : [File],
  description  : String,
  comments     : [Comment],
  category     : String,
  infohash     : {type: String, index: {unique:true}}
  permalink    : {type: String, index: {unique:true}}
}

Torrent.method 'generatePermalink', (callback) ->
  baseurl = @title.substring(0, 75).replace(`/ /g`, '_')
  # check for collisions
  checkFunc = (base, endno) =>
    if endno > 0
      url = base + '-' + endno
    else
      url = base
    (mongoose.model 'Torrent').findOne {'permalink' : url}, (err, doc) =>
      if doc
        checkFunc base, endno+1
      else
        @permalink = url
{'fraction_non_alphanumeric': 0.1309935739001483, 'fraction_numerical': 0.004943153732081068, 'mean_word_length': 2.4657534246575343, 'pattern_counts': {'":': 0, '<': 10, '<?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': '91069', 'n_tokens_mistral': 680, 'n_tokens_neox': 677, 'n_words': 185}