Example #1
0
def campaign_1():
    result_matrix = pd.DataFrame({
        'subreddit': [],
        'url': [],
        'hours ago': [],
        'location data': []
    })

    subs = [
        'whatcarshouldibuy', 'askcarguys', 'askcarsales', 'toyota', 'honda',
        'hyundai', 'ford', 'mazda', 'audi', 'lexus', 'mercedes_benz', 'bmw',
        'subaru', 'dodge', 'kia', 'nissan', 'ferrari', 'porsche', 'corvette',
        'mitsubishi', 'jaguar', 'landrover', 'volvo', 'scion', 'autos', 'cars'
    ]

    for i in range(len(subs)):
        result_matrix = print_links_of_sub(subs[i],
                                           result_matrix,
                                           q_terms="CAD|km",
                                           result_size_max=15,
                                           after_days='1d')

    pd.options.display.max_colwidth = 700
    result_matrix = result_matrix.sort_values(by='hours ago', ascending=True)

    send_email("*****@*****.**", result_matrix.to_string())
Example #2
0
def reminder():
    try:
        results = engine.execute("SELECT eventId, userId FROM reminders WHERE send_date < CURDATE() + INTERVAL 1 DAY")
        data = []
        # for result in results:
        #     userId = result[0]
        #     eventId = result[1]
        #     event, success = get_event(eventId)
        #     user, success = get_user(userId)
        #     data.append({"user": user, "event": event})

        data = [{"user": {"firstName":"janny", "emailAddress":"*****@*****.**"}, "event": {"eventName":"pick up dogs","startDateTime":"2019-10-10"}}]

        for i in data:
            email = i["user"]["emailAddress"]
            Name = i["user"]["firstName"]
            event_name = i["event"]["eventName"]
            # email, Name, event_name
            text1="We just want to remind you that your event {} is happening tomorrow!.".format(event_name)
            text2="Thank you, and we hope to see you!"
            send_email(email, "Event Fully Suscribed!", render_template('index.html',name = Name, text1=text1.format(event_name), text2=text2))
        return "Completed", 200
    except Exception as e:
        print(e)
        return str(e), 500
Example #3
0
def EventCancelled():
    try:
        eventId = request.args.get("eventId")
        event, success = get_event(eventId)
        event_name = event['eventName']
        event_date = event['startDateTime'][0:10]
        response = requests.get(eventsEndpoint+"/register?eventId="+eventId)
        json_data = json.loads(response.text)
        participants = []
        for i in json_data:
            participants.append(i["participant_id"])

        for i in participants:
            user,succes = get_user(i)
            if success:
                Name = user['firstName']
                email = user["emailAddress"]

                text1="Your event {} scheduled for {} has been cancelled!".format(event_name,event_date)
                text2 = ""
                template = render_template('index.html', name = Name, text1 = text1)
                send_email(email, "Event Fully Suscribed!", )
        return "Completed", 200
    except Exception as e:
        return str(e), 500
Example #4
0
def get_data(request):
    try:
        request_json = request.get_json(silent=True)
        if (request_json and 'folder_name' in request_json
                and 'email' in request_json):
            input_data = str(request_json['folder_name'])
            receiver = str(request_json['email'])
            people_folder = download_pictures('People')
            chat_path = download_file(input_data, 'chat')
            transcript_path = download_file(input_data, 'transcript')
            video_path = download_file(input_data, 'video')
            output_folder = '/tmp/output/'
            if not os.path.exists(output_folder):
                os.mkdir(output_folder)
            formatted_chat_path = '/tmp/chat_as_audio.vtt'

            chat_to_audio(chat_path, formatted_chat_path)
            processing_chat_data(formatted_chat_path, output_folder)
            processing_transcript_data(transcript_path, output_folder)
            process_video(video_path, people_folder, output_folder)

            output_senti = os.path.join(output_folder, 'sentiment.png')
            sentimentMain(chat_path, output_senti)
            send_email(output_folder, receiver)
            return "200"
        return "404"
    except Exception as e:
        return str(traceback.format_exc())
Example #5
0
def campaign_3():
    result_matrix = pd.DataFrame({'subreddit': [ ], 'url': [], 'hours ago': [], 'location data': []})

    subs = ['askTO', 'brampton', 'PersonalFinanceCanada']

    for i in range(len(subs)):
        result_matrix = print_links_of_sub(subs[i], result_matrix, q_terms=q_t, result_size_max=15, after_days='1d')

    pd.options.display.max_colwidth = 700
    result_matrix = result_matrix.sort_values(by='hours ago', ascending=True)
    
    send_email("*****@*****.**", result_matrix.to_string())
def campaign_2():
    result_matrix = pd.DataFrame({
        'subreddit': [],
        'url': [],
        'hours ago': [],
        'location data': []
    })

    subs = ['whatcarshouldibuy']

    for i in range(len(subs)):
        result_matrix = cmpn2helper(subs[i], result_matrix)

    pd.options.display.max_colwidth = 700
    result_matrix = result_matrix.sort_values(by='hours ago', ascending=True)

    send_email("*****@*****.**", result_matrix.to_string())
Example #7
0
def campaign_5():
    result_matrix = pd.DataFrame({
        'subreddit': [],
        'url': [],
        'hours ago': [],
        'location data': []
    })

    result_matrix = print_links_of_sub(result_matrix,
                                       q_terms=q_t,
                                       result_size_max=8,
                                       after_days='36d')

    pd.options.display.max_colwidth = 700
    result_matrix = result_matrix.sort_values(by='hours ago', ascending=True)

    send_email("*****@*****.**", result_matrix.to_string())
Example #8
0
def CallForAction():
    try:
        eventId = request.args.get("eventId")
        userIds = [1,2,3,4]
        event, success = get_event(eventId)
        for userId in userIds:
            user, success = get_user(userId)
        Name = user["firstName"]
        email = user["emailAddress"]
        event_name = event['eventName']
        event_date = event['startDateTime']
        text1="Your event {} scheduled for {} has been fully suscribed!"
        text2 = ""
        send_email(email, "Event Fully Suscribed!", render_template('index.html', name = Name, text1 = text1.format(event_name,event_date), text2=text2))
        return "Completed", 200
    except Exception as e:
        print(e)
        return str(e), 500
Example #9
0
def update():
    try:
        req_data = request.get_json()
        results = engine.execute(text("SELECT userId FROM reminders WHERE eventId = :eventId"), eventId = req_data['eventId'])
        #Whether they are updating date or the users
        type = req_data['type']
        eventId = req_data['eventId']
        #type can be users_rm, users_add, date_change
        if type == 'users_rm':
            userId = req_data['userId']
            removeUsers(db,eventId,userId)
        elif type == 'users_add':
            userId = req_data['userId']
            addUsers(db,eventId,userId)
        elif type == 'date_change':
            newDate = req_data['newDate']
            details = getEvent(db,eventId, newDate)
            changeDate(db,eventId, newDate)

            users = details["users"]
            event_name = details["event_name"]
            date1 = details["date"]
            new_date = newDate
            message1 = "{} on {} has been rescheduled to {}. We apologize for the inconvinience caused!".format(event_name,date1, new_date)
            message2 = ""

            userIds = engine.execute(text("SELECT userId FROM reminders WHERE eventId = :eventId"), eventId = req_data['eventId'])
            for userId in userIds:
                User = get_user(userId)
                User_Name = User["firstName"]
                User_email = User["emailAddress"]

                template = render_template('index.html',name = User_Name, text1=message1, text2=message1)
                send_email(User_email,"Date Of Event Changed!", template)
        return "Completed", 200
    except Exception as e:
        print(e)
        return str(e), 500
Example #10
0
def FullSub():
    try:
        userId = request.args.get("userId")
        eventId = request.args.get("eventId")
        email = request.args.get("email")
        # print(userId, eventId)
        print(userId)
        user, success = get_user(userId)
        print("got here" + str(userId))
        event, success = get_event(eventId)
        user, success = {"firstName":"janny"}, True
        event, success = {"eventName":"pick up dogs","startDateTime":"2019-10-10"}, True
        Name = user["firstName"]
        event_name = event['eventName']
        event_date = event['startDateTime']
        text1="Your event {} scheduled for {} has been fully suscribed!"
        text2 = ""
        if email != "":
            email = user["emailAddress"]
        send_email(email, "Event Fully Suscribed!", render_template('index.html', name = Name, text1 = text1.format(event_name,event_date), text2=text2))
        return "Completed", 200
    except Exception as e:
        return str(e), 500