* Modified storeHandsPlayers() so it returns a dictionary of handId & playerId to handPlayerIds
* Filled storeHandsActions() with the required information * Updated Hand.insert so that it calls storeHandsActions() and added the variable dbid_hpid to receive the new dictionary
This commit is contained in:
parent
1b0db117ce
commit
a76e34598d
|
@ -1676,6 +1676,7 @@ class Database:
|
||||||
pp.pprint(pdata)
|
pp.pprint(pdata)
|
||||||
|
|
||||||
inserts = []
|
inserts = []
|
||||||
|
hpid = {}
|
||||||
for p in pdata:
|
for p in pdata:
|
||||||
inserts.append( (hid,
|
inserts.append( (hid,
|
||||||
pids[p],
|
pids[p],
|
||||||
|
@ -1780,39 +1781,41 @@ class Database:
|
||||||
#print "DEBUG: inserts: %s" %inserts
|
#print "DEBUG: inserts: %s" %inserts
|
||||||
#print "DEBUG: q: %s" % q
|
#print "DEBUG: q: %s" % q
|
||||||
c = self.get_cursor()
|
c = self.get_cursor()
|
||||||
c.executemany(q, inserts)
|
|
||||||
|
for r in inserts:
|
||||||
|
c.execute(q, r)
|
||||||
|
hpid[(r[0], r[1])] = self.get_last_insert_id(c)
|
||||||
|
|
||||||
|
return hpid
|
||||||
|
|
||||||
def storeHandsActions(self, hid, pids, adata, printdata = False):
|
def storeHandsActions(self, hid, pids, hpid, adata, printdata = False):
|
||||||
#print "DEBUG: %s %s %s" %(hid, pids, adata)
|
#print "DEBUG: %s %s %s" %(hid, pids, adata)
|
||||||
if printdata:
|
if printdata:
|
||||||
import pprint
|
import pprint
|
||||||
pp = pprint.PrettyPrinter(indent=4)
|
pp = pprint.PrettyPrinter(indent=4)
|
||||||
pp.pprint(adata)
|
pp.pprint(adata)
|
||||||
|
|
||||||
#inserts = []
|
inserts = []
|
||||||
#for p in pdata:
|
for a in adata:
|
||||||
# inserts.append( (hid,
|
inserts.append( (hpid[(hid, pids[adata[a]['player']])],
|
||||||
# pids[p],
|
#self.getHandsPlayerId(self.hid, pids[adata[a]['player']]),
|
||||||
# adata[p]['startCash'],
|
adata[a]['street'],
|
||||||
# adata[p]['seatNo'],
|
adata[a]['actionNo'],
|
||||||
# adata[p]['sitout'],
|
adata[a]['streetActionNo'],
|
||||||
# adata[p]['card1'],
|
adata[a]['actionId'],
|
||||||
|
adata[a]['amount'],
|
||||||
#handsPlayerId BIGINT UNSIGNED NOT NULL, FOREIGN KEY (handsPlayerId) REFERENCES HandsPlayers(id),
|
adata[a]['raiseTo'],
|
||||||
#street SMALLINT NOT NULL,
|
adata[a]['amountCalled'],
|
||||||
#actionNo SMALLINT NOT NULL,
|
adata[a]['numDiscarded'],
|
||||||
#action CHAR(5) NOT NULL,
|
adata[a]['cardsDiscarded'],
|
||||||
#allIn BOOLEAN NOT NULL,
|
adata[a]['allIn']
|
||||||
#amount INT NOT NULL,
|
) )
|
||||||
|
|
||||||
|
|
||||||
q = self.sql.query['store_hands_actions']
|
q = self.sql.query['store_hands_actions']
|
||||||
#q = q.replace('%s', self.sql.query['placeholder'])
|
q = q.replace('%s', self.sql.query['placeholder'])
|
||||||
|
|
||||||
#print "DEBUG: inserts: %s" %inserts
|
c = self.get_cursor()
|
||||||
#print "DEBUG: q: %s" % q
|
c.executemany(q, inserts)
|
||||||
#c = self.get_cursor()
|
|
||||||
#c.executemany(q, inserts)
|
|
||||||
|
|
||||||
def storeHudCache(self, gid, pids, starttime, pdata):
|
def storeHudCache(self, gid, pids, starttime, pdata):
|
||||||
"""Update cached statistics. If update fails because no record exists, do an insert."""
|
"""Update cached statistics. If update fails because no record exists, do an insert."""
|
||||||
|
|
|
@ -67,6 +67,7 @@ class Hand(object):
|
||||||
self.cancelled = False
|
self.cancelled = False
|
||||||
self.dbid_hands = 0
|
self.dbid_hands = 0
|
||||||
self.dbid_pids = None
|
self.dbid_pids = None
|
||||||
|
self.dbid_hpid = None
|
||||||
self.dbid_gt = 0
|
self.dbid_gt = 0
|
||||||
self.tablename = ""
|
self.tablename = ""
|
||||||
self.hero = ""
|
self.hero = ""
|
||||||
|
@ -264,10 +265,11 @@ db: a connected Database object"""
|
||||||
hh['seats'] = len(self.dbid_pids)
|
hh['seats'] = len(self.dbid_pids)
|
||||||
|
|
||||||
self.dbid_hands = db.storeHand(hh)
|
self.dbid_hands = db.storeHand(hh)
|
||||||
db.storeHandsPlayers(self.dbid_hands, self.dbid_pids, self.stats.getHandsPlayers(), printdata = printtest)
|
self.dbid_hpid = db.storeHandsPlayers(self.dbid_hands, self.dbid_pids,
|
||||||
# TODO HandsActions - all actions for all players for all streets - self.actions
|
self.stats.getHandsPlayers(), printdata = printtest)
|
||||||
# HudCache data can be generated from HandsActions (HandsPlayers?)
|
|
||||||
#db.storeHandsActions(self.dbid_hands, self.dbid_pids, self.stats.getHandsActions(), printdata = printtest)
|
db.storeHandsActions(self.dbid_hands, self.dbid_pids, self.dbid_hpid,
|
||||||
|
self.stats.getHandsActions(), printdata = printtest)
|
||||||
else:
|
else:
|
||||||
log.info(_("Hand.insert(): hid #: %s is a duplicate") % hh['siteHandNo'])
|
log.info(_("Hand.insert(): hid #: %s is a duplicate") % hh['siteHandNo'])
|
||||||
self.is_duplicate = True # i.e. don't update hudcache
|
self.is_duplicate = True # i.e. don't update hudcache
|
||||||
|
|
Loading…
Reference in New Issue
Block a user