Database: Reformat a some tournament results update code

Reformat to make life easier when debugging
This commit is contained in:
Worros 2011-03-10 18:01:25 +08:00 committed by Steffen Schaumburg
parent 56db34ae05
commit 72f6a1ce6a

View File

@ -2359,8 +2359,9 @@ class Database:
def createOrUpdateTourney(self, hand, source):#note: this method is used on Hand and TourneySummary objects def createOrUpdateTourney(self, hand, source):#note: this method is used on Hand and TourneySummary objects
cursor = self.get_cursor() cursor = self.get_cursor()
cursor.execute (self.sql.query['getTourneyByTourneyNo'].replace('%s', self.sql.query['placeholder']), q = self.sql.query['getTourneyByTourneyNo'].replace('%s', self.sql.query['placeholder'])
(hand.siteId, hand.tourNo)) cursor.execute(q, (hand.siteId, hand.tourNo))
columnNames=[desc[0] for desc in cursor.description] columnNames=[desc[0] for desc in cursor.description]
result=cursor.fetchone() result=cursor.fetchone()
@ -2385,9 +2386,12 @@ class Database:
# if (resultDict[ev] < hand.startTime): # if (resultDict[ev] < hand.startTime):
# hand.startTime=resultDict[ev] # hand.startTime=resultDict[ev]
if updateDb: if updateDb:
cursor.execute (self.sql.query['updateTourney'].replace('%s', self.sql.query['placeholder']), q = self.sql.query['updateTourney'].replace('%s', self.sql.query['placeholder'])
(hand.entries, hand.prizepool, hand.startTime, hand.endTime, hand.tourneyName, row = (hand.entries, hand.prizepool, hand.startTime, hand.endTime, hand.tourneyName,
hand.matrixIdProcessed, hand.totalRebuyCount, hand.totalAddOnCount, hand.comment, hand.commentTs, tourneyId)) hand.matrixIdProcessed, hand.totalRebuyCount, hand.totalAddOnCount, hand.comment,
hand.commentTs, tourneyId
)
cursor.execute(q, row)
else: else:
if source=="HHC": if source=="HHC":
cursor.execute (self.sql.query['insertTourney'].replace('%s', self.sql.query['placeholder']), cursor.execute (self.sql.query['insertTourney'].replace('%s', self.sql.query['placeholder']),
@ -2436,9 +2440,19 @@ class Database:
elif getattr(hand, handAttribute)[player]!=None and resultDict[ev]==None:#object has this value but DB doesnt, so update DB elif getattr(hand, handAttribute)[player]!=None and resultDict[ev]==None:#object has this value but DB doesnt, so update DB
updateDb=True updateDb=True
if updateDb: if updateDb:
cursor.execute (self.sql.query['updateTourneysPlayer'].replace('%s', self.sql.query['placeholder']), q = self.sql.query['updateTourneysPlayer'].replace('%s', self.sql.query['placeholder'])
(hand.ranks[player], hand.winnings[player], hand.winningsCurrency[player], inputs = (hand.ranks[player],
hand.rebuyCounts[player], hand.addOnCounts[player], hand.koCounts[player], tourneysPlayersIds[player[1]])) hand.winnings[player],
hand.winningsCurrency[player],
hand.rebuyCounts[player],
hand.addOnCounts[player],
hand.koCounts[player],
tourneysPlayersIds[player[1]]
)
#print q
#pp = pprint.PrettyPrinter(indent=4)
#pp.pprint(inputs)
cursor.execute(q, inputs)
else: else:
if source=="HHC": if source=="HHC":
cursor.execute (self.sql.query['insertTourneysPlayer'].replace('%s', self.sql.query['placeholder']), cursor.execute (self.sql.query['insertTourneysPlayer'].replace('%s', self.sql.query['placeholder']),