[NEWIMPORT] Stop duplicate hands from crashing import

This commit is contained in:
Worros 2009-11-25 16:29:30 +08:00
parent 83f06c35cc
commit aee9a7339c
2 changed files with 31 additions and 15 deletions

View File

@ -1672,6 +1672,15 @@ class Database:
# street4CheckCallRaiseChance,
# street4CheckCallRaiseDone)
def isDuplicate(self, gametypeID, siteHandNo):
dup = False
c = self.get_cursor()
c.execute(self.sql.query['isAlreadyInDB'], (gametypeID, siteHandNo))
result = c.fetchall()
if len(result) > 0:
dup = True
return dup
def getGameTypeId(self, siteid, game):
c = self.get_cursor()
#FIXME: Fixed for NL at the moment
@ -1711,6 +1720,13 @@ class Database:
q = "SELECT name, id FROM Players WHERE siteid=%s and name=%s"
q = q.replace('%s', self.sql.query['placeholder'])
#NOTE/FIXME?: MySQL has ON DUPLICATE KEY UPDATE
#Usage:
# INSERT INTO `tags` (`tag`, `count`)
# VALUES ($tag, 1)
# ON DUPLICATE KEY UPDATE `count`=`count`+1;
#print "DEBUG: name: %s site: %s" %(name, site_id)
c.execute (q, (site_id, name))

View File

@ -210,24 +210,24 @@ db: a connected fpdb_db object"""
#####
# End prep functions
#####
# HandsActions - all actions for all players for all streets - self.actions
# HudCache data can be generated from HandsActions (HandsPlayers?)
# Hands - Summary information of hand indexed by handId - gameinfo
hh = self.stats.getHands()
hh['gameTypeId'] = gtid
# seats TINYINT NOT NULL,
hh['seats'] = len(sqlids)
#print hh
handid = db.storeHand(hh)
# HandsPlayers - ? ... Do we fix winnings?
db.storeHandsPlayers(handid, sqlids, self.stats.getHandsPlayers())
# Tourneys ?
# TourneysPlayers
if not db.isDuplicate(gtid, hh['siteHandNo']):
# Hands - Summary information of hand indexed by handId - gameinfo
hh['gameTypeId'] = gtid
# seats TINYINT NOT NULL,
hh['seats'] = len(sqlids)
pass
handid = db.storeHand(hh)
db.storeHandsPlayers(handid, sqlids, self.stats.getHandsPlayers())
# HandsActions - all actions for all players for all streets - self.actions
# HudCache data can be generated from HandsActions (HandsPlayers?)
# Tourneys ?
# TourneysPlayers
else:
log.info("Hand.insert(): hid #: %s is a duplicate" % hh['siteHandNo'])
#Raise Duplicate exception?
pass
def select(self, handId):
""" Function to create Hand object from database """