Fixed several errors in the new storeHudCache which were preventing the data from being imported in full
This commit is contained in:
parent
d98a28ea0a
commit
c518c482ac
|
@ -2109,6 +2109,7 @@ class Database:
|
||||||
insert_hudcache = insert_hudcache.replace('%s', self.sql.query['placeholder'])
|
insert_hudcache = insert_hudcache.replace('%s', self.sql.query['placeholder'])
|
||||||
|
|
||||||
#print "DEBUG: %s %s %s" %(hid, pids, pdata)
|
#print "DEBUG: %s %s %s" %(hid, pids, pdata)
|
||||||
|
hcs = []
|
||||||
for p in pdata:
|
for p in pdata:
|
||||||
#NOTE: Insert new stats at right place because SQL needs strict order
|
#NOTE: Insert new stats at right place because SQL needs strict order
|
||||||
line = []
|
line = []
|
||||||
|
@ -2201,7 +2202,7 @@ class Database:
|
||||||
line.append(pdata[p]['street3Raises'])
|
line.append(pdata[p]['street3Raises'])
|
||||||
line.append(pdata[p]['street4Raises'])
|
line.append(pdata[p]['street4Raises'])
|
||||||
|
|
||||||
hc, hcs = {}, []
|
hc = {}
|
||||||
hc['gametypeId'] = gid
|
hc['gametypeId'] = gid
|
||||||
hc['playerId'] = pids[p]
|
hc['playerId'] = pids[p]
|
||||||
hc['activeSeats'] = len(pids)
|
hc['activeSeats'] = len(pids)
|
||||||
|
@ -2221,6 +2222,7 @@ class Database:
|
||||||
for h in hcs:
|
for h in hcs:
|
||||||
match = False
|
match = False
|
||||||
for b in hcbulk:
|
for b in hcbulk:
|
||||||
|
#print h['game']==b['game'], h['game'], b['game']
|
||||||
if h['game']==b['game']:
|
if h['game']==b['game']:
|
||||||
b['line'] = [sum(l) for l in zip(b['line'], h['line'])]
|
b['line'] = [sum(l) for l in zip(b['line'], h['line'])]
|
||||||
match = True
|
match = True
|
||||||
|
@ -2228,14 +2230,9 @@ class Database:
|
||||||
|
|
||||||
if doinsert:
|
if doinsert:
|
||||||
inserts = []
|
inserts = []
|
||||||
exists = []
|
c = self.get_cursor()
|
||||||
updates = []
|
|
||||||
for hc in hcbulk:
|
for hc in hcbulk:
|
||||||
row = hc['line'] + hc['game']
|
row = hc['line'] + hc['game']
|
||||||
if hc['game'] in exists:
|
|
||||||
updates.append(row)
|
|
||||||
continue
|
|
||||||
c = self.get_cursor()
|
|
||||||
num = c.execute(update_hudcache, row)
|
num = c.execute(update_hudcache, row)
|
||||||
# Try to do the update first. Do insert it did not work
|
# Try to do the update first. Do insert it did not work
|
||||||
if ((self.backend == self.PGSQL and c.statusmessage != "UPDATE 1")
|
if ((self.backend == self.PGSQL and c.statusmessage != "UPDATE 1")
|
||||||
|
@ -2246,11 +2243,11 @@ class Database:
|
||||||
#num = c.execute(insert_hudcache, row)
|
#num = c.execute(insert_hudcache, row)
|
||||||
#print "DEBUG: Successfully(?: %s) updated HudCacho using INSERT" % num
|
#print "DEBUG: Successfully(?: %s) updated HudCacho using INSERT" % num
|
||||||
else:
|
else:
|
||||||
exists.append(hc['game'])
|
|
||||||
#print "DEBUG: Successfully updated HudCacho using UPDATE"
|
#print "DEBUG: Successfully updated HudCacho using UPDATE"
|
||||||
if inserts: c.executemany(insert_hudcache, inserts)
|
pass
|
||||||
if updates: c.executemany(update_hudcache, updates)
|
if inserts:
|
||||||
|
c.executemany(insert_hudcache, inserts)
|
||||||
|
|
||||||
return hcbulk
|
return hcbulk
|
||||||
|
|
||||||
def prepSessionsCache(self, hid, pids, startTime, sc, heros, doinsert = False):
|
def prepSessionsCache(self, hid, pids, startTime, sc, heros, doinsert = False):
|
||||||
|
|
|
@ -495,7 +495,7 @@ class Importer:
|
||||||
hbulk = hand.insertHands(self.database, hbulk, fileId, doinsert, self.settings['testData'])
|
hbulk = hand.insertHands(self.database, hbulk, fileId, doinsert, self.settings['testData'])
|
||||||
hcbulk = hand.updateHudCache(self.database, hcbulk, doinsert)
|
hcbulk = hand.updateHudCache(self.database, hcbulk, doinsert)
|
||||||
ihands.append(hand)
|
ihands.append(hand)
|
||||||
to_hud.append(id)
|
to_hud.append(hand.dbid_hands)
|
||||||
except Exceptions.FpdbHandDuplicate:
|
except Exceptions.FpdbHandDuplicate:
|
||||||
duplicates += 1
|
duplicates += 1
|
||||||
self.database.commit()
|
self.database.commit()
|
||||||
|
@ -512,7 +512,7 @@ class Importer:
|
||||||
if self.caller:
|
if self.caller:
|
||||||
for hid in to_hud:
|
for hid in to_hud:
|
||||||
try:
|
try:
|
||||||
print _("fpdb_import: sending hand to hud"), hand.dbid_hands, "pipe =", self.caller.pipe_to_hud
|
print _("fpdb_import: sending hand to hud"), hid, "pipe =", self.caller.pipe_to_hud
|
||||||
self.caller.pipe_to_hud.stdin.write("%s" % (hid) + os.linesep)
|
self.caller.pipe_to_hud.stdin.write("%s" % (hid) + os.linesep)
|
||||||
except IOError, e:
|
except IOError, e:
|
||||||
log.error(_("Failed to send hand to HUD: %s") % e)
|
log.error(_("Failed to send hand to HUD: %s") % e)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user