Ejemplo n.º 1
0
def panel_meeting(mgr, interval):

    hours = [[] for a in mgr]
    interview = [[] for a in mgr]
    realavail = [[] for a in mgr]
    i = 0

    for a in mgr:
        print i
        hours[i] = get_data('sp_demo_manager_hours', [a, 0, interval])
        interview[i] = get_data('sp_get_mg_interview', [a])
        realavail[i] = availability(hours[i], interview[i], interval)
        i += 1

    i = 0
    arr = []
    for a in mgr:
        print i
        if (i == 0):
            print 'do nothing first time around'
        elif (i == 1):
            arr = setup(realavail[i - 1], realavail[i])
        else:
            arr = setup(arr, realavail[i])
        i += 1
    return arr
Ejemplo n.º 2
0
def or_full_join_method(mgr, interval):
    hours = [[] for a in mgr]
    interview = [[] for a in mgr]
    realavail = [[] for a in mgr]
    i = 0

    for a in mgr:
        print i
        hours[i] = get_data('sp_demo_manager_hours', [a, 0, interval])
        interview[i] = get_data('sp_get_mg_interview', [a])
        realavail[i] = availability(hours[i], interview[i], interval)
        i += 1

    i = 0
    return_real_avail = copy.deepcopy(realavail)
    arr = []
    for a in mgr:
        print i
        if (i == 0):
            print 'first loop'
            if (len(mgr) == 1):
                return realavail[i], return_real_avail
        elif (i == 1):
            alist, blist, merged = pre_overlap(realavail[i - 1], realavail[i])
            newarr1 = post_overlap(realavail[i - 1], alist)
            newarr2 = post_overlap(realavail[i], blist)
            arr = sorted(dedup_multiD_list(merged) + newarr1 + newarr2)
        else:
            alist, blist, merged = pre_overlap(arr, realavail[i])
            newarr1 = post_overlap(arr, alist)
            newarr2 = post_overlap(realavail[i], blist)
            arr = sorted(dedup_multiD_list(merged) + newarr1 + newarr2)
        i += 1
    print 'or_full_join return'
    return arr, return_real_avail
Ejemplo n.º 3
0
def send_sms_email(the_email):
    client = boto3.client('sns')

    data = get_data('sp_confirm', [the_email])
    logger.debug(data)

    if (data):
        a = data[0]

        starttime = a[4].strftime('%I:%M %p')
        endtime = a[5].strftime('%I:%M %p')
        theday = a[4].strftime('%Y-%m-%d')
        cleanphone = clean_phone_no(a[2])
        therole = a[9]

        msg = 'Hi ' + a[
            0] + '!  Thank you for scheduling your interview.  We have you booked on ' + theday + ' from ' + starttime + ' to ' + endtime + ' with ' + a[
                6] + ' in ' + a[
                    7] + ' for the ' + therole + ' role.  See you then!'

        comm = a[3].lower()
        if (comm == 'both' or comm == 'sms'):
            client.publish(PhoneNumber=cleanphone, Message=msg)
            b = get_data('sp_log_message', [the_email, 1, 1])

        if (comm == 'both' or comm == 'email'):
            send_one_email(a[1], msg, 'Interview Confirmation')
            b = get_data('sp_log_message', [the_email, 2, 1])
    else:
        logger.debug('nothing for this email ...' + str(the_email))
Ejemplo n.º 4
0
def setup():
	formater() 
	navail = get_data('sp_demo_manager_hours', [3, 0, 20])
	interv =  get_data('sp_get_mg_interview', [3])
	x, y = 0, 0

	for i in interv:
		x += 1
		y=0
		print ' outer loop ' + str(x)
		avail = navail
		navail = []
		innerloop = array(avail).shape[0]

		for k in range(innerloop):
			a = avail[y]
			y += 1
			print 'inner loop ..' + str(y)

			yn, arr = overlap_fn(a[0], a[1], i[0], i[1])
			if (yn):
				j = some_date_logic(arr, a[0], a[1])
				navail = navail + j


	print navail
Ejemplo n.º 5
0
def set1():
    client = boto3.client('sns')
    notifications = get_data('sp_notify', [])
    for a in notifications:
        comm = a[11].lower()
        starttime = a[0].strftime('%I:%M %p')
        endtime = a[1].strftime('%I:%M %p')
        theday = a[0].strftime('%Y-%m-%d')
        cleanphone = clean_phone_no(a[9])
        emailadd = a[8]
        therole = a[12]
        thekey = a[13]
        interviewid = a[3]

        msg = 'Hi ' + a[
            10] + '!  Unfortunately we have to reschedule your interview that was scheduled for ' + theday + ' from ' + starttime + ' to ' + endtime + ' for the ' + therole + ' role.  Please follow this link to reschedule.  Thank you! <a class="ulink" href="http://chat.adri-hr.com?id=' + thekey + ' " target="_blank">Link to Audrey</a>'

        if (comm == 'both' or comm == 'sms'):
            client.publish(PhoneNumber=cleanphone, Message=msg)

        if (comm == 'both' or comm == 'email'):
            send_one_email(emailadd, msg, 'Interview Reschedule')

        b = get_data('sp_notified', [interviewid])

        print msg
Ejemplo n.º 6
0
def begin_here(s1=sys.argv[1], s2=sys.argv[2], s3=sys.argv[3]):
    #returns array with [managerid, start time, end time, solution id]
    # s1, s2, s3 = [1,2,3], 45, random_number

    mgr, int_len, random_number = build_arg(s1, s2, s3)

    hours = rtn_2_of_3(get_data('sp_demo_manager_hours', [mgr, 0, int_len]))
    inter = get_data('sp_get_mg_interview', [mgr])
    newarr = availability(hours, inter, int_len)
    insertfinal = build_insert(newarr, random_number, mgr)
    insert_many_answer(insertfinal)

    sys.stdout.flush()
Ejemplo n.º 7
0
def get_each_available(mgr, interval):
	hours = [[] for a in mgr]
	interview = [[] for a in mgr]
	realavail = [[] for a in mgr]
	i = 0

	for a in mgr:
		print i
		hours[i] = get_data('sp_demo_manager_hours', [a, 0, interval])
		interview[i] = get_data('sp_get_mg_interview', [a])
		realavail[i] = availability(hours[i], interview[i], interval)
		i += 1

	i = 0
	return realavail 
Ejemplo n.º 8
0
def get_recent_data():
    with open("/assets/state.json") as f:
        last_pulled_json = json.load(f)
        last_pulled_date = last_pulled_json['last_pulled_date']

    print("Last pulled date: ", last_pulled_date)
    # Get current time
    now = datetime.now().strftime('%Y-%m-%d %H:%M:%S')

    print("Now: ", now)

    # pull data from database between the last pulled date and now
    data = get_data("Box0", last_pulled_date, now)

    # update json file with current date
    #last_pulled_json['last_pulled_date'] = now
    #with open("/assets/state.json", "w") as jsonFile:
    #    json.dump(last_pulled_json, jsonFile)

    df = pd.DataFrame(
        data, columns=['box_name', 'channel_name', 'time', 'value', 'label'])
    #print("\ngot " + str(len(df)) + " rows of data. processing data......")
    df.sort_values(by='time', inplace=True)
    df.reset_index(inplace=True)
    df.drop('index', axis=1, inplace=True)
    print(df.head())

    return df
Ejemplo n.º 9
0
def contrast_data():
    """
    三个品牌折线图数据发送
    """
    if request.method == "POST":
        data = get_data("contrast_data")
        # 保留三位小数
        data_t = [[round(i, 3) for i in i_list] for i_list in data]
        return jsonify(data=data_t)
Ejemplo n.º 10
0
def send1():
    prospects = get_data('sp_send_email', [])

    for a in prospects:
        themessage = 'Hi ' + a[
            2] + '!  Welcome to ADRI!  Please follow the link to the chatbot to begin your interview process. <a class="ulink" href="http://chat.adri-hr.com/" target="_blank">Link to Audrey</a>.'

        if (len(a[3]) > 9):
            send_sms(a[3], themessage)
            print themessage
Ejemplo n.º 11
0
def text_all_prospects():
    prospects = get_data('sp_send_email', [])

    for a in prospects:
        if (a[0] == 6):
            themessage = 'Hi ' + a[
                2] + '!  Welcome to ADRI!  Please follow the link to the chatbot to begin your interview process. <a class="ulink" href="http://chat.adri-hr.com?id=' + a[
                    5] + '" target="_blank">Link to Audrey</a>.'

            if (len(a[3]) > 9):
                boto3_sms_aws(clean_phone_no(a[3]), themessage)
                print themessage
Ejemplo n.º 12
0
def validate_manager_availability(slots, the_manager):
    logger.debug('validate_manager_availability')
    the_time = try_ex(lambda: slots['timeslot'])
    the_date = try_ex(lambda: slots['dateslot'])
    logger.debug('inside the validate_manager_availability')
    intv_len = 20

    if (the_date):
        hours = get_data('sp_demo_manager_hours', [the_manager, 0, intv_len])
        inter = get_data('sp_get_mg_interview', [the_manager])
        thedates = availability(hours, inter, intv_len)

        newdate = datetime.datetime.strptime(the_date, '%Y-%m-%d')

        if (newdate.date() not in (d.date() for d, c, g in thedates)):
            return build_validation_result(
                False, 'dateslot', 'Please enter a date from the list above.')

    if (the_time):
        if (not isvallid_time(the_time)):
            return build_validation_result(False, 'timeslot',
                                           'Please enter a valid time.')

        hours = get_data('sp_demo_manager_hours',
                         [the_manager, the_date, intv_len])
        inter = get_data('sp_get_mg_interview', [the_manager])
        thedates = availability(hours, inter, intv_len)

        newtime = datetime.datetime.strptime(the_time, '%H:%M').time()

        if (any((newtime >= row[0].time() and newtime <= row[2].time())
                for row in thedates)):
            logger.debug('timeslot validated.')
        else:
            return build_validation_result(
                False, 'timeslot',
                'Please enter a start time that allows for a ' +
                str(intv_len) + ' minute interview.')

    return {'isValid': True}
Ejemplo n.º 13
0
def get_availability_details(intent_request):
    #collect user information we use role and location to determine the manager
    session_attributes = intent_request['sessionAttributes'] if intent_request[
        'sessionAttributes'] is not None else {}
    slots = intent_request['currentIntent']['slots']
    interested_in_job = slots['interested']
    emailaddress = slots['emailaddress']
    emailexists = slots['emailexists']
    the_name = slots['name']
    slots['step'] = 0
    the_user = intent_request['userId']
    alertyn = slots['alertyn']

    if (emailaddress and not alertyn):
        title = 'new lead... ' + str(emailaddress)
        send_one_email('*****@*****.**', title, title)
        slots['alertyn'] = 'sent'

    if (not emailaddress):
        return pre_elicit_slot(intent_request, 'emailaddress',
                               'Please enter your email address.')

    if (emailaddress and not the_name):

        rtn_fullname = get_data('sp_demo_getemail_name', [emailaddress])
        if (rtn_fullname):
            handle_stored_procecure('sp_set_personcode',
                                    [emailaddress, the_user])
            the_name = str(rtn_fullname[0])[2:-3]
        elif (not rtn_fullname):
            slots['emailexists'] = 'no'
            return pre_elicit_slot(intent_request, 'name',
                                   'What is your name?')

    if (emailaddress and the_name and emailexists == 'no'):
        handle_stored_procecure('sp_add_person',
                                [the_user, the_name, emailaddress])
        slots['emailexists'] = 'yes'

    if (not interested_in_job):
        return pre_elicit_slot(
            intent_request, 'interested',
            'Hi ' + the_name + '!  Are you available immediately?')

    if (interested_in_job == 'no'):
        return follow_up_later(intent_request)

    elif (interested_in_job == 'yes'):
        return intrested_in_job_fn(intent_request)
        raise Exception('Bombed out in the get_availability_details')
Ejemplo n.º 14
0
def get_contact_information(intent_request):
    logger.debug('get_contact_information')
    session_attributes = intent_request['sessionAttributes'] if intent_request[
        'sessionAttributes'] is not None else {}
    slots = intent_request['currentIntent']['slots']
    the_name = slots['name']
    the_mobile = slots['mobile']
    emailaddress = slots['emailaddress']
    sms_email = slots['sms_email']
    the_position = slots['Position']
    the_user = intent_request['userId']
    slots['step'] = 3

    if (the_position == 'none'):
        return follow_up_later(intent_request)

    data = get_data('sp_get_contact_info', [the_user])
    dbmobilie = data[0][2]
    dbsms_email = data[0][3]

    if (not the_mobile):
        if (has_data(dbmobilie, 10)):
            logger.debug('we already have phone number in database')
            the_mobile = dbmobilie
            slots['mobile'] = dbmobilie
        else:
            return pre_elicit_slot(intent_request, 'mobile',
                                   'What is your cell phone number?')

    if (not sms_email):
        if (has_data(dbsms_email, 3)):
            sms_email = dbsms_email
            slots['sms_email'] = dbsms_email
        else:
            return pre_elicit_slot(
                intent_request, 'sms_email',
                'Would you prefer we reach you via sms, email or both?  Please say either "sms", "email" or "both".'
            )

    slots['step'] = 4
    handle_stored_procecure('sp_set_person', [the_user, the_mobile, sms_email])
    return manager_availability_routine(intent_request)

    raise Exception('Bombed out in the get_contact_information')
Ejemplo n.º 15
0
from app import get_data
from app import today


list_of_words = get_data('goog', 'google', today(), today())
for words in list_of_words:
    print(words)
Ejemplo n.º 16
0
def test_get_data():
    result = get_data()
    return result
Ejemplo n.º 17
0
def test_get_data():
    assert_that(
        get_data(get_data_file(os.path.join(test_root(),
                                            'get_data_file')))).is_not_empty()
Ejemplo n.º 18
0
def manager_availability_routine(intent_request):
    logger.debug('inside the manager_availability_routine')
    session_attributes = intent_request['sessionAttributes'] if intent_request[
        'sessionAttributes'] is not None else {}
    slots = intent_request['currentIntent']['slots']
    the_time = slots['timeslot']
    the_date = slots['dateslot']
    the_user = intent_request['userId']
    emailaddress = slots['emailaddress']
    intv_len = 20
    slots['step'] = 4

    the_manager = get_data('sp_get_managerid', [the_user])
    """
    this is where you would call the OR routine or_full_join.py file
    like this
    or_full_join_method([1,2,3], 20)
    
    implement this after you setup the table for "N" managers per job opening


    """
    if (any(row[0] == -1 for row in the_manager)):
        themessage = 'We could not find the role and location you requested.'
        return pre_elicit_slot(intent_request, 'dateslot', themessage)

    validation_result = validate_manager_availability(slots, the_manager)
    if not validation_result['isValid']:
        slots[validation_result['violatedSlot']] = None
        return violated_slot(intent_request, validation_result)

    if (not the_date):
        hours = get_data('sp_demo_manager_hours', [the_manager, 0, intv_len])
        inter = get_data('sp_get_mg_interview', [the_manager])
        thedates = availability(hours, inter, intv_len)

        theresult = []
        for row in thedates:
            theresult.append(row[0].strftime('%m/%d/%Y %I:%M %p') + ' - ' +
                             row[1].strftime('%I:%M %p'))

        values = ', '.join(str(v) for v in theresult)
        themessage = 'Please choose the date then time.  Which day would you like to interview? We have these slots available \n' + values + '.'

        if not thedates:
            validation_result = build_validation_result(
                False, 'dateslot', 'Error.  Manager not available.')
            slots[validation_result['violatedSlot']] = None
            return violated_slot(intent_request, validation_result)

        return pre_elicit_slot(intent_request, 'dateslot', themessage)

    if (not the_time):
        hours = get_data('sp_demo_manager_hours',
                         [the_manager, the_date, intv_len])
        inter = get_data('sp_get_mg_interview', [the_manager])
        thedates = availability(hours, inter, intv_len)

        theresult = []
        for row in thedates:
            theresult.append(row[0].strftime('%I:%M %p') + ' - ' +
                             row[1].strftime('%I:%M %p'))

        values = ', '.join(str(v) for v in theresult)

        themessage = 'Which time would you like to schedule an interview? We have ' + values + ' available. Please specify am/pm in your answer.'
        return pre_elicit_slot(intent_request, 'timeslot', themessage)

    if (the_time and the_date and the_manager):

        newdate = datetime.datetime.strptime(the_date, '%Y-%m-%d')
        newtime = datetime.datetime.strptime(the_time, '%H:%M').time()
        combined_date = datetime.datetime.combine(newdate, newtime)
        logger.debug(combined_date)

        handle_stored_procecure('sp_set_interview',
                                [the_user, the_manager, combined_date])

        rtn_msg = 'Thank you!  We will contact the recruiter and will be in touch with you soon!  In the meantime please take a minute to send your updated resume to [email protected]. \r'

        #send_confirmation(emailaddress)
        send_sms_email(emailaddress)

        return close(session_attributes, 'Fulfilled', {
            'contentType': 'PlainText',
            'content': rtn_msg
        })

    raise Exception('Bombed out in the manager_availability_routine')
Ejemplo n.º 19
0
def intrested_in_job_fn(intent_request):
    logger.debug('intrested_in_job_fn')
    session_attributes = intent_request['sessionAttributes'] if intent_request[
        'sessionAttributes'] is not None else {}
    slots = intent_request['currentIntent']['slots']
    the_city = slots['Location']
    the_position = slots['Position']
    the_mobile = slots['mobile']
    emailaddress = slots['emailaddress']
    the_user = intent_request['userId']
    slots['step'] = 2
    companyid = 2

    if (has_data(the_mobile)):
        logger.debug('skipping to get_contact_information')
        return get_contact_information(intent_request)
    else:
        if (not the_city):
            cities = get_data('sp_get_city', [companyid])
            sentence = ', '.join(city[0] for city in cities)
            return pre_elicit_slot(
                intent_request, 'Location',
                'Here is a list of cities we have current openings in ' +
                sentence + '.  Or you can say "none".')

        if (the_city == 'none'):
            return follow_up_later(intent_request)

        if (the_city and not the_position):
            theroles = get_data('sp_get_locationid', [the_city, companyid])

            if not theroles:
                kd = get_data('sp_missed_loc', [the_user, the_city])
                #send_sms_email(emailaddress)
                rtn_msg = 'We have recorded your city preference and will follow up with you when we have openings in ' + the_city + '.  Thank you!'
                return close(session_attributes, 'Fulfilled', {
                    'contentType': 'PlainText',
                    'content': rtn_msg
                })

            sentence = ', '.join(word[3] for word in theroles)
            themessage = 'Which position are you interested in?  We have ' + sentence + ' roles available.  If none of these roles are of interest please say "none".'
            return pre_elicit_slot(intent_request, 'Position', themessage)

        if (the_position):
            if (the_position == 'none'):
                return follow_up_later(
                    intent_request,
                    'We don\'t have any other job options for ' + the_city +
                    ' currently.  May we follow up with you at a later date?')

            theroles = get_data('sp_get_locationid', [the_city, companyid])
            if (the_position.lower()
                    not in (row[3].lower() for row in theroles)):
                return pre_elicit_slot(intent_request, 'Position',
                                       'Please enter a role listed above.')

            slots['stepa'] = 1
            handle_stored_procecure(
                'sp_set_person1',
                [emailaddress, the_city, the_position, companyid])
            handle_stored_procecure('sp_demo_set_interest',
                                    [emailaddress, 'yes'])
            slots['step'] = 3
            return get_contact_information(intent_request)
Ejemplo n.º 20
0
def follow_up_later(intent_request, custommsg=''):
    session_attributes = intent_request['sessionAttributes'] if intent_request[
        'sessionAttributes'] is not None else {}
    slots = intent_request['currentIntent']['slots']
    laterdate = slots['laterdate']
    laterdateyn = slots['laterdateyn']
    emailaddress = slots['emailaddress']
    the_mobile = slots['mobile']
    sms_email = slots['sms_email']
    the_user = intent_request['userId']
    slots['step'] = 1

    if (custommsg == ''):
        custommsg = 'May we follow up with you at a later date?'

    if (not laterdateyn):
        return pre_elicit_slot(intent_request, 'laterdateyn', custommsg)

    if (laterdateyn == 'no'):
        handle_stored_procecure('sp_demo_set_interest', [emailaddress, 'no'])
        return close(
            session_attributes, 'Fulfilled', {
                'contentType':
                'PlainText',
                'content':
                'Thanks, we understand that you are not interested.  Good luck to you!'
            })

    if (laterdateyn == 'yes' and not laterdate):
        return pre_elicit_slot(intent_request, 'laterdate',
                               'What date may we follow up?')

    if (laterdateyn == 'yes' and laterdate):

        data = get_data('sp_get_contact_info', [the_user])
        if (data):
            dbmobilie = data[0][2]
            dbsms_email = data[0][3]
            if (has_data(dbmobilie, 10)):
                the_mobile = dbmobilie
                slots['mobile'] = dbmobilie

            if (has_data(dbsms_email, 3)):
                sms_email = dbsms_email
                slots['sms_email'] = dbsms_email

        if (not sms_email):
            return pre_elicit_slot(
                intent_request, 'sms_email',
                'Would you prefer we reach you via sms, email or both?  Please say either "sms", "email" or "both".'
            )

        if (not the_mobile):
            if (sms_email == 'both' or sms_email == 'sms'):
                return pre_elicit_slot(intent_request, 'mobile',
                                       'What is your cell phone number?')

        end_date = laterdate
        slots['step'] = 2
        handle_stored_procecure('sp_demo_set_interest', [emailaddress, 'yes'])
        handle_stored_procecure('sp_demo_later_date', [emailaddress, end_date])
        return close(
            session_attributes, 'Fulfilled', {
                'contentType': 'PlainText',
                'content':
                'Thank you!  We will follow up with you on ' + end_date
            })
Ejemplo n.º 21
0
def send1():
    prospects = get_data('sp_send_email', [])

    for a in prospects:
        send_emailv2(a[1], a[2], a[5])