예제 #1
0
def pending_requests():
    '''This function handles the requests that the user has sent to other users, stores and displays them'''
    recieved = current_user().sent_pending()
    counter = 0
    searchMatches = []
    try:
        for person in recieved:
            if (counter > 45):
                break
            info = []
            userDOB = current_user().dob.split("-")
            this = util.matchmaker.Person(userDOB[0], userDOB[1], userDOB[2])
            otherDOB = User.query_by_id(person, "dob").split("-")
            other = util.matchmaker.Person(
                otherDOB[0], otherDOB[1],
                otherDOB[2])  #Person object for other user
            other_user = User(person)
            info.append(other_user.name)
            info.append(
                round((util.matchmaker.personalityCompatibility(this, other)) *
                      100))
            info.append(
                round(
                    (util.matchmaker.sexualCompatibility(this, other)) * 100))
            info.append(
                round(
                    (util.matchmaker.inLawsCompatibility(this, other)) * 100))
            info.append(
                round((util.matchmaker.futureSuccess(this, other)) * 100))
            info.append(other_user.bio)
            info.append(person)
            info.append(round(current_user().user_dist(person)))
            info.append(other_user.get_starsign().capitalize())
            info.append(starsign_compatibilites[current_user().get_starsign()][
                other_user.get_starsign()])
            counter += 1
            searchMatches.append(info)
    except Exception as e:
        print(e)
    session["prev_url"] = "/requests/pending"
    return render_template("pending_requests.html", listings=searchMatches)
예제 #2
0
def matchmaking():
    '''The matchmaking function measures compatibility with other users in the database using available user data,
    and displays the data'''
    # return f"{current_user().unmatched()}"
    counter = 0
    searchMatches = []
    print(current_user().unmatched())
    for person in current_user().unmatched():
        if (counter > 45):
            break
        # try:
        info = []
        userDOB = current_user().dob.split("-")
        this = util.matchmaker.Person(userDOB[0], userDOB[1], userDOB[2])
        otherDOB = User.query_by_id(person, "dob").split("-")
        other = util.matchmaker.Person(
            otherDOB[0], otherDOB[1],
            otherDOB[2])  #Person object for other user
        other_user = User(person)
        info.append(other_user.name)
        info.append(
            round(
                (util.matchmaker.personalityCompatibility(this, other)) * 100))
        info.append(
            round((util.matchmaker.sexualCompatibility(this, other)) * 100))
        info.append(
            round((util.matchmaker.inLawsCompatibility(this, other)) * 100))
        info.append(round((util.matchmaker.futureSuccess(this, other)) * 100))
        info.append(other_user.bio)
        info.append(person)
        info.append(round(current_user().user_dist(person)))
        info.append(other_user.get_starsign().capitalize())
        info.append(starsign_compatibilites[current_user().get_starsign()][
            other_user.get_starsign()])
        counter += 1
        searchMatches.append(info)
        # except Exception as e:
        #     print(e)
    searchMatches.sort(key=lambda x: x[7])
    session["prev_url"] = "/hotsingles"
    return render_template("matchmaking.html", listings=searchMatches)