示例#1
0
def update_entrant_id_to_player_id_dict_and_player_database(list_of_player_tags, final_tag_list, challonge_player_dicts):
	entrant_id_to_player_id_dict = {}


	for player_dict in challonge_player_dicts:
		print "currently in this dict", player_dict["name"]
		for original_challonge_tag, updated_database_tag in zip(list_of_player_tags, final_tag_list):
			if original_challonge_tag == player_dict["name"]:
				entrant_id = player_dict["id"]

				rows = database.queryMany("SELECT * FROM players WHERE tag=%s", (updated_database_tag[0],))
				print "printing rows for update entrant id func"
				print rows


				if (len(rows) < 1) and not updated_database_tag[1]:
					print "inserting"
					tag = str(updated_database_tag[0].lower())
					display_tag = str(player_dict['name'])
					trueskill_mu = trueskillapi.defaultRating.mu 
					trueskill_sigma = trueskillapi.defaultRating.sigma 
					state = "WA"
					player_tuple = (tag, display_tag, trueskill_mu, trueskill_sigma, state)
					cur = database.queryInsertNoRow("INSERT INTO players(tag, display_tag, trueskill_mu, trueskill_sigma, location) VALUES (%s, %s, %s, %s, %s) RETURNING id;", player_tuple)
					id_of_new_row = cur.fetchone()[0]
					entrant_id_to_player_id_dict[entrant_id] = id_of_new_row

				elif (len(rows) == 1):
					entrant_id_to_player_id_dict[entrant_id] = rows[0][0]
				else:
					print ("multiple tags for tag: {}".format((updated_database_tag[0],)))
					print rows


	return entrant_id_to_player_id_dict 
示例#2
0
def create_db_tag_list_for_comparison():
	database_tag_list = []
	rows = database.queryMany("SELECT tag FROM players")

	for row in rows:
		database_tag_list.append((row[0]))

	return database_tag_list
示例#3
0
def check_for_alternate_tags(final_tag_list):
	shin_final_tag_list = []
	alternate_tags_dict = {}
	rows = database.queryMany("SELECT alt_tag, db_player_id FROM alternate_tags")

	for row in rows:
		alternate_tags_dict[row[0].lower().strip()] = row[1]
	print alternate_tags_dict
	for final_tag in final_tag_list:
		if not final_tag[1] and (final_tag[0] in alternate_tags_dict.keys()):
			player_id = alternate_tags_dict[final_tag[0]]
			row = database.queryOne("SELECT tag FROM players WHERE id= %s", (player_id,))

			print "row", row
			print "row[0]", row[0]
			final_tag = (row[0], True)
			shin_final_tag_list.append(final_tag)	
		else:
			shin_final_tag_list.append(final_tag)
	print "shin_final_tag_list", shin_final_tag_list
	return shin_final_tag_list
示例#4
0
def update_entrant_id_to_player_id_dict_and_player_database(tourneyName, eventName, gamertag_to_sggplayerid_dict):
	entrant_id_to_player_id_dict = {}

	tourney_players = smash.tournament_show_players(tourneyName, eventName)
	#doesn't work with BRACKETS THAT HAVE NOBODY IN THEM
	print "length of tourney players is ", len(tourney_players)
	print "length of ditionarykeys is ", len(gamertag_to_sggplayerid_dict.keys())


	for bracket_player in tourney_players:
		entrant_id = (bracket_player["entrant_id"])
		tag = bracket_player["tag"].lower()
		tag_tuple = (tag,)
		sgg_player_id = gamertag_to_sggplayerid_dict[bracket_player["tag"]]
		rows = database.queryMany("SELECT * FROM players WHERE sgg_player_id=%s", (sgg_player_id,))
		
		if (len(rows) < 1):
			tag = (bracket_player["tag"].lower())
			display_tag = (bracket_player["tag"])
			fname = (bracket_player["fname"])
			lname = (bracket_player["lname"])
			location = str(bracket_player["state"])
			trueskill_mu = trueskillapi.defaultRating.mu 
			trueskill_sigma = trueskillapi.defaultRating.sigma 
			sgg_player_id = gamertag_to_sggplayerid_dict[display_tag]
			player_tuple = (tag, display_tag, fname, lname, location, trueskill_mu, trueskill_sigma, sgg_player_id)
			print player_tuple
			cur = database.queryInsertNoRow("INSERT INTO players(tag, display_tag, fname, lname, location, trueskill_mu, trueskill_sigma, sgg_player_id) VALUES (%s, %s, %s, %s, %s, %s, %s, %s) RETURNING id;", player_tuple)
			print "printing cur?"
			print cur
			id_of_new_row = cur.fetchone()[0]
			entrant_id_to_player_id_dict[entrant_id] = id_of_new_row

		elif (len(rows) == 1):
			entrant_id_to_player_id_dict[entrant_id] = rows[0][0]

		else:
			print("Multiple Tags for tag: {}".format(tag_tuple))

	return entrant_id_to_player_id_dict 
示例#5
0
def get_all_sponsors():
	sponsors = []
	rows = database.queryMany("""SELECT sponsor from sponsors;""")
	for row in rows:
		sponsors.append(row[0])
	return sponsors