Class: TechAdTagger
- Defined in:
- lib/whos_using_what/data_gatherers/tech_ad_tagger.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize ⇒ TechAdTagger
constructor
A new instance of TechAdTagger.
-
#tag_company_with_technologies(tech_keywords, search_query_url_generator_closure) ⇒ Object
iterates through array and updates company db record with technologies found from ads from their website.
Methods inherited from Base
Constructor Details
#initialize ⇒ TechAdTagger
Returns a new instance of TechAdTagger.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/whos_using_what/data_gatherers/tech_ad_tagger.rb', line 5 def initialize require_relative '../api_clients/google_client' @search_client = GoogleClient.new @mongo_client = MongoHelper.get_mongo_connection @companies_coll = @mongo_client['companies'] end |
Instance Method Details
#tag_company_with_technologies(tech_keywords, search_query_url_generator_closure) ⇒ Object
iterates through array and updates company db record with technologies found from ads from their website
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/whos_using_what/data_gatherers/tech_ad_tagger.rb', line 19 def tag_company_with_technologies tech_keywords, search_query_url_generator_closure # uncomment if need to clear out all existing technologies =begin @companies_coll.find().each do |company| company['languages'] = {} @companies_coll.update({"_id" => company["_id"]}, company) end =end companies = @companies_coll.find( # "languages" => {"$exists" => false} # "languages" => {} ).to_a languages = Hash.new companies.each do |company| languages = Hash.new company_languages_map = @search_client.perform_search tech_keywords, company["websiteUrl"], search_query_url_generator_closure company_languages_map.each do |key, value| languages[key] = value end company['languages'] = languages @companies_coll.update({"_id" => company["_id"]}, company) puts "updating: " << company.to_s end end |