[NEWIMPORT] Remove a couple of unused functions
This commit is contained in:
parent
0adf0a7b18
commit
46e91e1a0f
|
@ -619,69 +619,6 @@ class Database:
|
|||
rows = c.fetchall()
|
||||
return rows
|
||||
|
||||
#returns the SQL ids of the names given in an array
|
||||
# TODO: if someone gets industrious, they should make the parts that use the output of this function deal with a dict
|
||||
# { playername: id } instead of depending on it's relation to the positions list
|
||||
# then this can be reduced in complexity a bit
|
||||
|
||||
#def recognisePlayerIDs(cursor, names, site_id):
|
||||
# result = []
|
||||
# for i in xrange(len(names)):
|
||||
# cursor.execute ("SELECT id FROM Players WHERE name=%s", (names[i],))
|
||||
# tmp=cursor.fetchall()
|
||||
# if (len(tmp)==0): #new player
|
||||
# cursor.execute ("INSERT INTO Players (name, siteId) VALUES (%s, %s)", (names[i], site_id))
|
||||
# #print "Number of players rows inserted: %d" % cursor.rowcount
|
||||
# cursor.execute ("SELECT id FROM Players WHERE name=%s", (names[i],))
|
||||
# tmp=cursor.fetchall()
|
||||
# #print "recognisePlayerIDs, names[i]:",names[i],"tmp:",tmp
|
||||
# result.append(tmp[0][0])
|
||||
# return result
|
||||
|
||||
def recognisePlayerIDs(self, names, site_id):
|
||||
c = self.get_cursor()
|
||||
q = "SELECT name,id FROM Players WHERE siteid=%d and (name=%s)" %(site_id, " OR name=".join([self.sql.query['placeholder'] for n in names]))
|
||||
c.execute(q, names) # get all playerids by the names passed in
|
||||
ids = dict(c.fetchall()) # convert to dict
|
||||
if len(ids) != len(names):
|
||||
notfound = [n for n in names if n not in ids] # make list of names not in database
|
||||
if notfound: # insert them into database
|
||||
q_ins = "INSERT INTO Players (name, siteId) VALUES (%s, "+str(site_id)+")"
|
||||
q_ins = q_ins.replace('%s', self.sql.query['placeholder'])
|
||||
c.executemany(q_ins, [(n,) for n in notfound])
|
||||
q2 = "SELECT name,id FROM Players WHERE siteid=%d and (name=%s)" % (site_id, " OR name=".join(["%s" for n in notfound]))
|
||||
q2 = q2.replace('%s', self.sql.query['placeholder'])
|
||||
c.execute(q2, notfound) # get their new ids
|
||||
tmp = c.fetchall()
|
||||
for n,id in tmp: # put them all into the same dict
|
||||
ids[n] = id
|
||||
# return them in the SAME ORDER that they came in in the names argument, rather than the order they came out of the DB
|
||||
return [ids[n] for n in names]
|
||||
#end def recognisePlayerIDs
|
||||
|
||||
# Here's a version that would work if it wasn't for the fact that it needs to have the output in the same order as input
|
||||
# this version could also be improved upon using list comprehensions, etc
|
||||
|
||||
#def recognisePlayerIDs(cursor, names, site_id):
|
||||
# result = []
|
||||
# notfound = []
|
||||
# cursor.execute("SELECT name,id FROM Players WHERE name='%s'" % "' OR name='".join(names))
|
||||
# tmp = dict(cursor.fetchall())
|
||||
# for n in names:
|
||||
# if n not in tmp:
|
||||
# notfound.append(n)
|
||||
# else:
|
||||
# result.append(tmp[n])
|
||||
# if notfound:
|
||||
# cursor.executemany("INSERT INTO Players (name, siteId) VALUES (%s, "+str(site_id)+")", (notfound))
|
||||
# cursor.execute("SELECT id FROM Players WHERE name='%s'" % "' OR name='".join(notfound))
|
||||
# tmp = cursor.fetchall()
|
||||
# for n in tmp:
|
||||
# result.append(n[0])
|
||||
#
|
||||
# return result
|
||||
|
||||
|
||||
def get_site_id(self, site):
|
||||
c = self.get_cursor()
|
||||
c.execute(self.sql.query['getSiteId'], (site,))
|
||||
|
@ -1680,45 +1617,6 @@ class Database:
|
|||
|
||||
|
||||
|
||||
def storeHands(self, backend, site_hand_no, gametype_id
|
||||
,hand_start_time, names, tableName, maxSeats, hudCache
|
||||
,board_values, board_suits):
|
||||
|
||||
cards = [Card.cardFromValueSuit(v,s) for v,s in zip(board_values,board_suits)]
|
||||
#stores into table hands:
|
||||
try:
|
||||
c = self.get_cursor()
|
||||
c.execute ("""INSERT INTO Hands
|
||||
(siteHandNo, gametypeId, handStart, seats, tableName, importTime, maxSeats
|
||||
,boardcard1,boardcard2,boardcard3,boardcard4,boardcard5
|
||||
,playersVpi, playersAtStreet1, playersAtStreet2
|
||||
,playersAtStreet3, playersAtStreet4, playersAtShowdown
|
||||
,street0Raises, street1Raises, street2Raises
|
||||
,street3Raises, street4Raises, street1Pot
|
||||
,street2Pot, street3Pot, street4Pot
|
||||
,showdownPot
|
||||
)
|
||||
VALUES
|
||||
(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,
|
||||
%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
|
||||
""".replace('%s', self.sql.query['placeholder'])
|
||||
, (site_hand_no, gametype_id, hand_start_time, len(names), tableName, datetime.today(), maxSeats
|
||||
,cards[0], cards[1], cards[2], cards[3], cards[4]
|
||||
,hudCache['playersVpi'], hudCache['playersAtStreet1'], hudCache['playersAtStreet2']
|
||||
,hudCache['playersAtStreet3'], hudCache['playersAtStreet4'], hudCache['playersAtShowdown']
|
||||
,hudCache['street0Raises'], hudCache['street1Raises'], hudCache['street2Raises']
|
||||
,hudCache['street3Raises'], hudCache['street4Raises'], hudCache['street1Pot']
|
||||
,hudCache['street2Pot'], hudCache['street3Pot'], hudCache['street4Pot']
|
||||
,hudCache['showdownPot']
|
||||
))
|
||||
ret = self.get_last_insert_id(c)
|
||||
except:
|
||||
ret = -1
|
||||
raise FpdbError( "storeHands error: " + str(sys.exc_value) )
|
||||
|
||||
return ret
|
||||
#end def storeHands
|
||||
|
||||
def store_tourneys_players(self, tourney_id, player_ids, payin_amounts, ranks, winnings):
|
||||
try:
|
||||
result=[]
|
||||
|
|
Loading…
Reference in New Issue
Block a user