<commit_before>module SchoolData

	def self.update_basic_info!
		School.all.each do |school|
			api_response = Faraday.new(:url => "https://apps.mybps.org/WebServiceDiscoverBPSv1.10/Schools.svc/GetSchool?schyear=2014&sch=#{school.bps_id}", :ssl => {:version => :SSLv3}).get.body
			if api_response.present?
				school.update_attributes(api_basic_info: MultiJson.load(api_response, :symbolize_keys => true).try(:[], 0)) # remove hash from array
				puts "********** updating basic info for school #{school.bps_id}"
			end
		end
	end

	def self.update_awards!
		School.all.each do |school|
			api_response = Faraday.new(:url => "https://apps.mybps.org/WebServiceDiscoverBPSv1.10/Schools.svc/GetSchoolAwards?schyear=2014&sch=#{school.bps_id}&TranslationLanguage=", :ssl => {:version => :SSLv3}).get.body
			if api_response.present?
				school.update_attributes(api_awards: MultiJson.load(api_response, :symbolize_keys => true)) 
				puts "********** updating awards for school #{school.bps_id}"
			end
		end
	end

	def self.update_descriptions!
		School.all.each do |school|<commit_msg>Update school name along with basic data<commit_after>module SchoolData

	def self.update_basic_info!
		School.all.each do |school|
			api_response = Faraday.new(:url => "https://apps.mybps.org/WebServiceDiscoverBPSv1.10/Schools.svc/GetSchool?schyear=2014&sch=#{school.bps_id}", :ssl => {:version => :SSLv3}).get.body
			if api_response.present?
				hash = MultiJson.load(api_response, :symbolize_keys => true).try(:[], 0)
				school.update_attributes(name: hash[:schname_23], api_basic_info: hash) # remove hash from array
				puts "********** updating basic info for school #{school.bps_id}"
			end
		end
	end

	def self.update_awards!
		School.all.each do |school|
			api_response = Faraday.new(:url => "https://apps.mybps.org/WebServiceDiscoverBPSv1.10/Schools.svc/GetSchoolAwards?schyear=2014&sch=#{school.bps_id}&TranslationLanguage=", :ssl => {:version => :SSLv3}).get.body
			if api_response.present?
				school.update_attributes(api_awards: MultiJson.load(api_response, :symbolize_keys => true)) 
				puts "********** updating awards for school #{school.bps_id}"
			end
		end
	end

	def self.update_descriptions!
		School.all.each do |school|
{'fraction_non_alphanumeric': 0.1521933751119069, 'fraction_numerical': 0.01611459265890779, 'mean_word_length': 5.1401098901098905, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '306097', 'n_tokens_mistral': 874, 'n_tokens_neox': 757, 'n_words': 139}