<commit_before>class User < ActiveRecord::Base

  has_many :interests

  validates_presence_of :lastfm_username

  # Param: either a string array of artist names, or an array of hashes with
  # keys :score and :name. The former assumes score 1 and is intended to be
  # used with artist names from the listening history; the latter with artist
  # names and scores as returned by LastFm::Artist.get_similar.
  #
  def create_interests(artists)

    artists.each do |item|

      if item.is_a? String
        name = item
        score = 1
      elsif item.is_a? Hash
        name = item[:name]
        score = item[:score].to_f
      elsif item.is_a? SimilarArtist
        name = item.name
        score = item.score
      end

      next if self.interests.exists?(:artist_name => name)

      self.interests.create(
        :score => score,
        :artist_name => name,<commit_msg>Add dependent => :destroy to user - interests.<commit_after>class User < ActiveRecord::Base

  has_many :interests, :dependent => :destroy

  validates_presence_of :lastfm_username

  # Param: either a string array of artist names, or an array of hashes with
  # keys :score and :name. The former assumes score 1 and is intended to be
  # used with artist names from the listening history; the latter with artist
  # names and scores as returned by LastFm::Artist.get_similar.
  #
  def create_interests(artists)

    artists.each do |item|

      if item.is_a? String
        name = item
        score = 1
      elsif item.is_a? Hash
        name = item[:name]
        score = item[:score].to_f
      elsif item.is_a? SimilarArtist
        name = item.name
        score = item.score
      end

      next if self.interests.exists?(:artist_name => name)

      self.interests.create(
        :score => score,
        :artist_name => name,
{'fraction_non_alphanumeric': 0.08017572762218561, 'fraction_numerical': 0.002196595277320154, 'mean_word_length': 2.622266401590457, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4779087', 'n_tokens_mistral': 557, 'n_tokens_neox': 540, 'n_words': 186}