Class: CompaniesSearcher
- Defined in:
- lib/whos_using_what/data_searchers/companies_searcher.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#find_people_for_company(linkedin_client, company_name, location) ⇒ Object
find people from a company, based off the user’s network and connections.
- #geospatial_search(lon, lat) ⇒ Object
-
#initialize(geo_tagger) ⇒ CompaniesSearcher
constructor
geo_tagger = instance of GeoTagger.
- #zip_code_search(zip_code) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(geo_tagger) ⇒ CompaniesSearcher
geo_tagger = instance of GeoTagger
6 7 8 9 10 11 12 13 14 |
# File 'lib/whos_using_what/data_searchers/companies_searcher.rb', line 6 def initialize geo_tagger @mongo_client = MongoHelper.get_mongo_connection @companies_coll = @mongo_client['companies'] @coords_coll = @mongo_client['coordinates'] @geo_tagger = geo_tagger end |
Instance Method Details
#find_people_for_company(linkedin_client, company_name, location) ⇒ Object
find people from a company, based off the user’s network and connections
24 25 26 27 28 |
# File 'lib/whos_using_what/data_searchers/companies_searcher.rb', line 24 def find_people_for_company linkedin_client, company_name, location puts linkedin_client.query_people_from_company company_name, location end |
#geospatial_search(lon, lat) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/whos_using_what/data_searchers/companies_searcher.rb', line 16 def geospatial_search lon, lat near = @companies_coll.find({"loc" => {"$near" => [lat, lon]}}) end |
#zip_code_search(zip_code) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/whos_using_what/data_searchers/companies_searcher.rb', line 30 def zip_code_search zip_code zip_doc = @coords_coll.find_one({:zip => zip_code}) if zip_doc == nil @geo_tagger.insert_new_zip_entry zip_code end zip_doc = @coords_coll.find_one({:zip => zip_code}) if zip_doc == nil return nil end results = geospatial_search zip_doc["loc"]["lon"], zip_doc["loc"]["lat"] results.to_a end |