Esempio n. 1
0
    def _add_reports(self, list_name, companies, company_list, _profile):
        company_list_id = company_list['objectId']
        _user, _company = companies[0]['user'], companies[0]['company']
        data = {'name': list_name, 'user': _user, 'company': _company}
        _company_list = Parse()._pointer('CompanyProspectList',
                                         company_list_id)
        data['parent_list'], data['list_type'] = _company_list, 'mining_job'
        _report = {
            'report_type': 'company_employee_mining_job',
            'profile': _profile
        }
        signal_report = Parse().create('SignalReport', _report).json()
        _report = Parse()._pointer('SignalReport', signal_report['objectId'])
        _list_id = Prospecter().create('ProspectList', data).json()['objectId']
        _prospect_list = Parse()._pointer('ProspectList', _list_id)
        _report = {'reports': {'__op': 'AddUnique', 'objects': [_report]}}
        _list = {
            'prospect_lists': {
                '__op': 'AddUnique',
                'objects': [_prospect_list]
            }
        }
        r = Prospecter().update('CompanyProspectList/' + company_list_id,
                                _list)
        rr = Prospecter().update('ProspectProfile/' + _profile['objectId'],
                                 _report)
        print r.json(), rr.json()

        return (signal_report['objectId'], _list_id)
Esempio n. 2
0
    def employee_webhook(self,
                         company_name,
                         company_list,
                         qry="",
                         limit=5,
                         list_id="",
                         _report=""):
        _user, _company = company_list['user'], company_list['company']
        employees = Companies()._employees(company_name, qry)
        company = Companies()._get_info(company_name)
        _company_list = company_list['objectId']
        for index, row in employees.iterrows():
            data = row.to_dict()
            company['user'], company['company'] = _user, _company
            prospect = company
            prospect['name'], prospect['pos'] = row['name'], row['title']
            prospect['city'] = row['locale']
            prospect['linkedin_url'] = row['linkedin_url']
            prospect['lists'] = [Parse()._pointer('ProspectList', list_id)]
            if type(company['industry']) is list:
                company['industry'] = company['industry'][0]
            prospect['company_profile'] = company_list['profile']
            r = Prospecter().create('Prospect', company)
            print "prospect_create_result", r.json()

        if RQueue()._has_completed("{0}_{1}".format(_company_list, list_id)):
            data = {'done': arrow.now().timestamp}
            r = Prospecter().update("SignalReport/" + _report, data)
            print "employee_webhook_has_completed -->", r.json()
Esempio n. 3
0
 def _update_company_email_pattern(self, data):
     if not data: return 0
     qry = {'where':json.dumps({'domain': data['domain']})}
     companies = Parse().get('Company', qry).json()
     while "error" in companies.keys():
         time.sleep(3)
         companies = Parse().get('Company', qry).json()
     companies = companies['results']
     pattern = {'email_pattern': data['company_email_pattern']}
     if data['company_email_pattern'] == []: 
         pattern['email_guess'] = []
     #_pusher['customero'].trigger(data["domain"], pattern)
     for company in companies:
         #print data
         data = {'email_pattern':data['company_email_pattern'], 
                 'email_pattern_research': arrow.utcnow().timestamp}
         r = Parse().update('Company/'+company['objectId'], data)
         # pusher -->
         print r.json()
         try:
           ''' print data["domain"] '''
         except:
           ''' print "wtf error ", data '''