<commit_before>class Gif < ActiveRecord::Base
  require 'uri'
  has_many :teams
  has_many :teamgifs
  
  validates :url, presence: true
  validates :word, presence: true
  
  def self.getgif(searchfor)
    return nil unless searchfor.present?
    encodedsearch = URI.encode(searchfor)
    url = "http://www.reactiongifs.com/?s=#{encodedsearch}&submit=Search"
    doc = Nokogiri::HTML(open(url))
    findgifs = doc.css('div.entry p a').map { |link| link['href'] }
    findgifs
  end
end
<commit_msg>start saving gif urls<commit_after>class Gif < ActiveRecord::Base
  require 'uri'
  has_many :teams
  has_many :teamgifs
  
  validates :url, presence: true
  #validates :word, presence: true
  
  def self.getgif(searchfor)
    return nil unless searchfor.present?
    encodedsearch = URI.encode(searchfor)
    url = "http://www.reactiongifs.com/?s=#{encodedsearch}&submit=Search"
    doc = Nokogiri::HTML(open(url))
    findgifs = doc.css('div.entry p a').map { |link| link['href'] }
    #save found gifs if they are new
    findgifs.each do |x|
        if Gif.find_by_url(x).nil?
            gif = Gif.new
            gif.url = x
            gif.save!
        end
    end
    findgifs
  end
  
end

{'fraction_non_alphanumeric': 0.12010008340283569, 'fraction_numerical': 0.0, 'mean_word_length': 3.0268456375838926, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2309309', 'n_tokens_mistral': 427, 'n_tokens_neox': 419, 'n_words': 98}