<commit_before>module SitesHelper
  def self.updateSites
    require 'net/http'
    url = URI.parse('http://api.stackexchange.com/2.2/sites?pagesize=1000&filter=!*L1-8Dpi2xJ-sYWj')
    req = Net::HTTP::Get.new(url.to_s)
    res = Net::HTTP.start(url.host, url.port) {|http|
      http.request(req)
    }
    sites = JSON.parse(res.body)["items"]
    puts sites
    if sites.count > 100 #all is well
      sites.each do |site|
        if Site.find_by_site_url(site["site_url"])  == nil
          s=Site.new
          s.site_url = site["site_url"]
          s.site_domain = URI.parse(s.site_url).host
          s.site_logo = site["favicon_url"].gsub(/http:/, "")
          s.site_name = site["name"]
          s.save!
        end
      end
    end
  end
end
<commit_msg>Update sites from sites helper instead of trying to create new ones<commit_after>module SitesHelper
  def self.updateSites
    require 'net/http'
    url = URI.parse('http://api.stackexchange.com/2.2/sites?pagesize=1000&filter=!*L1-8Dpi2xJ-sYWj')
    req = Net::HTTP::Get.new(url.to_s)
    res = Net::HTTP.start(url.host, url.port) {|http|
      http.request(req)
    }
    sites = JSON.parse(res.body)["items"]
    puts sites
    if sites.count > 100 #all is well
      sites.each do |site|
        s = Site.find_or_create_by(:site_url => site["site_url"])
        s.site_url = site["site_url"]
        s.site_domain = URI.parse(s.site_url).host
        s.site_logo = site["favicon_url"].gsub(/http:/, "")
        s.site_name = site["name"]
        s.save!
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.1492921492921493, 'fraction_numerical': 0.015444015444015444, 'mean_word_length': 2.5583524027459954, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '6857762', 'n_tokens_mistral': 590, 'n_tokens_neox': 575, 'n_words': 101}