<commit_before>include TimeHelpers


class Track
  include Mongoid::Document
  include Mongoid::Timestamps::Created


  field :path_and_file, type: String
  field :file_contents_hash, type: String
  field :onset_times, type: Array
  field :onset_count, type: Integer
  field :track_missing, type: Boolean, default: false
  field :mp3_data_string, type: String



  def self.import_tracks
    # track_list_string = `mdfind -name \.mp3`
    track_list_string = `find ~/  -name *.mp3`
    track_list__wav_string = ''# `find ~/  -name *.wav`
    tracks_array = track_list_string.split("\n")
    tracks_array =  tracks_array + track_list__wav_string.split("\n")
    # puts tracks_array
    puts "#{tracks_array.size} tracks to check"

    # remove Track records when there is no underlying file
    missing_files = Track.nin(path_and_file: tracks_array)
    missing_files.each  do |missing_file|<commit_msg>add guard clause around external volume mount<commit_after>include TimeHelpers


class Track
  include Mongoid::Document
  include Mongoid::Timestamps::Created


  field :path_and_file, type: String
  field :file_contents_hash, type: String
  field :onset_times, type: Array
  field :onset_count, type: Integer
  field :track_missing, type: Boolean, default: false
  field :mp3_data_string, type: String



  def self.import_tracks
    # track_list_string = `mdfind -name \.mp3`
    track_list_string = `find ~/  -name *.mp3`
    if system("mount|grep /BIG_GUY")
      track_list_string += `find /Volumes/BIG_GUY/dc_tunez/  -name *.mp3`
    end
    track_list__wav_string = ''# `find ~/  -name *.wav`
    tracks_array = track_list_string.split("\n")
    tracks_array =  tracks_array + track_list__wav_string.split("\n")
    # puts tracks_array
    puts "#{tracks_array.size} tracks to check"

    # remove Track records when there is no underlying file
    missing_files = Track.nin(path_and_file: tracks_array)
    missing_files.each  do |missing_file|
{'fraction_non_alphanumeric': 0.09769820971867008, 'fraction_numerical': 0.0035805626598465474, 'mean_word_length': 4.054263565891473, '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': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2236081', 'n_tokens_mistral': 664, 'n_tokens_neox': 641, 'n_words': 164}