From 9a3d60e0b3f8f5fbd4958b054948655643902199 Mon Sep 17 00:00:00 2001 From: Worros Date: Wed, 1 Sep 2010 10:47:13 +0800 Subject: [PATCH] HandsActions: Stub in the remaining calls for HandsActions --- pyfpdb/Database.py | 24 ++++++++++++++++++++++++ pyfpdb/DerivedStats.py | 6 +++++- pyfpdb/Hand.py | 1 + 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py index f1b8dd72..9037e082 100644 --- a/pyfpdb/Database.py +++ b/pyfpdb/Database.py @@ -1756,6 +1756,30 @@ class Database: c = self.get_cursor() c.executemany(q, inserts) + def storeHandsPlayers(self, hid, pids, adata, printdata = False): + #print "DEBUG: %s %s %s" %(hid, pids, adata) + if printdata: + import pprint + pp = pprint.PrettyPrinter(indent=4) + pp.pprint(adata) + + #inserts = [] + #for p in pdata: + # inserts.append( (hid, + # pids[p], + # adata[p]['startCash'], + # adata[p]['seatNo'], + # adata[p]['sitout'], + # adata[p]['card1'], + + #q = self.sql.query['store_hands_actions'] + #q = q.replace('%s', self.sql.query['placeholder']) + + #print "DEBUG: inserts: %s" %inserts + #print "DEBUG: q: %s" % q + #c = self.get_cursor() + #c.executemany(q, inserts) + def storeHudCache(self, gid, pids, starttime, pdata): """Update cached statistics. If update fails because no record exists, do an insert.""" diff --git a/pyfpdb/DerivedStats.py b/pyfpdb/DerivedStats.py index 56222e18..40646342 100644 --- a/pyfpdb/DerivedStats.py +++ b/pyfpdb/DerivedStats.py @@ -34,8 +34,9 @@ class DerivedStats(): def __init__(self, hand): self.hand = hand - self.hands = {} + self.hands = {} self.handsplayers = {} + self.handsactions = {} def getStats(self, hand): @@ -107,6 +108,9 @@ class DerivedStats(): def getHandsPlayers(self): return self.handsplayers + def getHandsActions(self): + return self.handsactions + def assembleHands(self, hand): self.hands['tableName'] = hand.tablename self.hands['siteHandNo'] = hand.handid diff --git a/pyfpdb/Hand.py b/pyfpdb/Hand.py index 7ae5f044..d653af3b 100644 --- a/pyfpdb/Hand.py +++ b/pyfpdb/Hand.py @@ -275,6 +275,7 @@ db: a connected Database object""" db.storeHandsPlayers(self.dbid_hands, self.dbid_pids, self.stats.getHandsPlayers(), printdata = printtest) # TODO HandsActions - all actions for all players for all streets - self.actions # HudCache data can be generated from HandsActions (HandsPlayers?) + #db.storeHandsActions(self.dbid_hands, self.dbid_pids, self.stats.getHandsActions(), printdata = printtest) else: log.info(_("Hand.insert(): hid #: %s is a duplicate") % hh['siteHandNo']) self.is_duplicate = True # i.e. don't update hudcache