Beispiel #1
0
def get_users_ratings_dict(db_conn_conf, user_ids):
    """Create dict with ratings for given users
    """
    db_conn = RSDBConnection(db_conn_conf)
    raw_ratings = {user_id: db_conn.get_user_ratings(user_id) for user_id in user_ids}
    db_conn.finalize()
    return format_data(raw_ratings), len(user_ids)
Beispiel #2
0
def show_user_ratings():
    """Show ratings for a given user
    """
    rsdbc = RSDBConnection()
    user_name = raw_input("Please enter your username\n")
    user_id = rsdbc.get_user_id(user_name)
    ratings = rsdbc.get_user_ratings(user_id)
    print '\n\nrating\t\t game'
    for elem in ratings:
        game_name = rsdbc.get_game_name(elem[0])
        print '{1}\t\t {0}'.format(game_name, elem[1])
    print "\n\n"
    rsdbc.finalize()
Beispiel #3
0
def create_dict_with_group_ratings():
    """Function that creates a dict with user ratings from our group
    """
    rsdbc = RSDBConnection()
    menu = {}
    menu['1'] = 'Add user to group'
    menu['0'] = 'End'
    user_ids = []
    ratings = {}
    game_ratings = {}
    while(True):
        options = menu.keys()
        options.sort()
        for entry in options:
            print entry, menu[entry]
        selection = raw_input("Please select: ")
        if selection == '1':
            user_name = raw_input("Please give the user name of existing user: ")
            user_id = rsdbc.get_user_id(user_name)
            user_ids.append(user_id)
        elif selection == '0':
            break
        else:
            print 'Wrong option!\n'
        for user_id in user_ids:
            rating = rsdbc.get_user_ratings(user_id)
            ratings[user_id] = rating
    rsdbc.finalize()

    for user_id, game_dict in ratings.iteritems():
        for game_id, rating in game_dict:
            if game_id in game_ratings:
                game_ratings[game_id] [user_id] = rating
            else:
                game_ratings[game_id] = {user_id:rating}
    return game_ratings, len(user_ids)
Beispiel #4
0
 def resulting_fun(db_conn_conf, user_ids, group_name):
     db_conn = RSDBConnection(db_conn_conf)
     ratings = db_conn.get_user_ratings(user_id)
     recommendations = read_recommendation_from_file(db_conn_conf, db_conn.get_user_name(user_id))
     db_conn.finalize()
     return ratings + recommendations