git2 - import now stores the first few fields into a new line.

little fix on load_profile - still doesnt work tho
This commit is contained in:
steffen123 2008-08-04 07:29:53 +01:00
parent f17e8b54b4
commit 67c2b3fe04
6 changed files with 77 additions and 25 deletions

View File

@ -3,10 +3,13 @@ todolist (db=database, imp=importer, tv=tableviewer)
before beta before beta
=========== ===========
current speedup attempt todo: current speedup attempt todo:
holdem in fpdb_simple done - now update remaining files, test, then add back postflop and stud functionality finish hud store todos in fpdb_simple
update tv
test
add back postflop and stud functionality
import fails on stud/razz change save_to_db into one method and probably move into parse_logic
tv doesnt display street 3-5 in stud/razz i think fix load profile
Any comment or print with "todo" in it in the sourcecode except what is marked todo in the menu Any comment or print with "todo" in it in the sourcecode except what is marked todo in the menu
find out if i can SQL for the rowcount, rather than select a field and then just take the rowcount. this might bring a significant performance improvement find out if i can SQL for the rowcount, rather than select a field and then just take the rowcount. this might bring a significant performance improvement
make a quick benchmark of mysql and postgresql: import of my whole db, some tableviewer refreshes with and without updated file make a quick benchmark of mysql and postgresql: import of my whole db, some tableviewer refreshes with and without updated file

View File

@ -17,5 +17,5 @@
rm testdata/*.found.txt rm testdata/*.found.txt
rm utils/*.pyc rm utils/*.pyc
rm fpdb-python/*.pyc rm pyfpdb/*.pyc
git-add--interactive git-add--interactive

View File

@ -159,7 +159,7 @@ class fpdb:
def dia_load_profile(self, widget, data): def dia_load_profile(self, widget, data):
"""Dialogue to select a file to load a profile from""" """Dialogue to select a file to load a profile from"""
obtain_global_lock() self.obtain_global_lock()
chooser = gtk.FileChooserDialog(title="Please select a profile file to load", chooser = gtk.FileChooserDialog(title="Please select a profile file to load",
action=gtk.FILE_CHOOSER_ACTION_OPEN, action=gtk.FILE_CHOOSER_ACTION_OPEN,
buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK)) buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK))

View File

@ -113,7 +113,7 @@ def mainParser(db, cursor, site, category, hand):
limit_type=cursor.fetchone()[0] #todo: remove this unnecessary database access limit_type=cursor.fetchone()[0] #todo: remove this unnecessary database access
fpdb_simple.convert3B4B(site, category, limit_type, actionTypes, actionAmounts) fpdb_simple.convert3B4B(site, category, limit_type, actionTypes, actionAmounts)
hands_players_flags=fpdb_simple.calculate_hands_players_flags(playerIDs, category, actionTypes) hudImportData=fpdb_simple.calculateHudImport(playerIDs, category, actionTypes)
if isTourney: if isTourney:
payin_amounts=fpdb_simple.calcPayin(len(names), buyin, fee) payin_amounts=fpdb_simple.calcPayin(len(names), buyin, fee)
@ -128,22 +128,22 @@ def mainParser(db, cursor, site, category, hand):
knockout, entries, prizepool, tourneyStartTime, payin_amounts, ranks, knockout, entries, prizepool, tourneyStartTime, payin_amounts, ranks,
siteHandNo, siteID, gametypeID, handStartTime, names, playerIDs, siteHandNo, siteID, gametypeID, handStartTime, names, playerIDs,
startCashes, positions, cardValues, cardSuits, boardValues, boardSuits, winnings, rakes, startCashes, positions, cardValues, cardSuits, boardValues, boardSuits, winnings, rakes,
actionTypes, actionAmounts, hands_players_flags) actionTypes, actionAmounts, hudImportData)
elif (category=="razz" or category=="studhi" or category=="studhilo"): elif (category=="razz" or category=="studhi" or category=="studhilo"):
result = fpdb_save_to_db.tourney_stud(cursor, category, siteTourneyNo, buyin, fee, result = fpdb_save_to_db.tourney_stud(cursor, category, siteTourneyNo, buyin, fee,
knockout, entries, prizepool, tourneyStartTime, payin_amounts, ranks, knockout, entries, prizepool, tourneyStartTime, payin_amounts, ranks,
siteHandNo, siteID, gametypeID, handStartTime, names, playerIDs, siteHandNo, siteID, gametypeID, handStartTime, names, playerIDs,
startCashes, antes, cardValues, cardSuits, winnings, rakes, startCashes, antes, cardValues, cardSuits, winnings, rakes,
actionTypes, actionAmounts, hands_players_flags) actionTypes, actionAmounts, hudImportData)
else: else:
if (category=="holdem" or category=="omahahi" or category=="omahahilo"): if (category=="holdem" or category=="omahahi" or category=="omahahilo"):
result = fpdb_save_to_db.ring_holdem_omaha(cursor, category, siteHandNo, gametypeID, result = fpdb_save_to_db.ring_holdem_omaha(cursor, category, siteHandNo, gametypeID,
handStartTime, names, playerIDs, startCashes, positions, cardValues, handStartTime, names, playerIDs, startCashes, positions, cardValues,
cardSuits, boardValues, boardSuits, winnings, rakes, actionTypes, actionAmounts, hands_players_flags) cardSuits, boardValues, boardSuits, winnings, rakes, actionTypes, actionAmounts, hudImportData)
elif (category=="razz" or category=="studhi" or category=="studhilo"): elif (category=="razz" or category=="studhi" or category=="studhilo"):
result = fpdb_save_to_db.ring_stud(cursor, category, siteHandNo, gametypeID, result = fpdb_save_to_db.ring_stud(cursor, category, siteHandNo, gametypeID,
handStartTime, names, playerIDs, startCashes, antes, cardValues, handStartTime, names, playerIDs, startCashes, antes, cardValues,
cardSuits, winnings, rakes, actionTypes, actionAmounts, hands_players_flags) cardSuits, winnings, rakes, actionTypes, actionAmounts, hudImportData)
else: else:
raise fpdb_simple.FpdbError ("unrecognised category") raise fpdb_simple.FpdbError ("unrecognised category")
db.commit() db.commit()

View File

@ -23,7 +23,7 @@ import fpdb_simple
#stores a stud/razz hand into the database #stores a stud/razz hand into the database
def ring_stud(cursor, category, site_hand_no, gametype_id, hand_start_time, def ring_stud(cursor, category, site_hand_no, gametype_id, hand_start_time,
names, player_ids, start_cashes, antes, card_values, card_suits, names, player_ids, start_cashes, antes, card_values, card_suits,
winnings, rakes, action_types, action_amounts, hands_players_flags): winnings, rakes, action_types, action_amounts, hudImportData):
fpdb_simple.fillCardArrays(len(names), 7, card_values, card_suits) fpdb_simple.fillCardArrays(len(names), 7, card_values, card_suits)
hands_id=fpdb_simple.storeHands(cursor, site_hand_no, gametype_id, hand_start_time, names) hands_id=fpdb_simple.storeHands(cursor, site_hand_no, gametype_id, hand_start_time, names)
@ -31,7 +31,7 @@ def ring_stud(cursor, category, site_hand_no, gametype_id, hand_start_time,
hands_players_ids=fpdb_simple.store_hands_players_stud(cursor, hands_id, player_ids, hands_players_ids=fpdb_simple.store_hands_players_stud(cursor, hands_id, player_ids,
start_cashes, antes, card_values, card_suits, winnings, rakes) start_cashes, antes, card_values, card_suits, winnings, rakes)
fpdb_simple.store_hands_players_flags(cursor, category, hands_players_ids, hands_players_flags) fpdb_simple.storeHudData(cursor, category, player_ids, hudImportData)
fpdb_simple.storeActions(cursor, hands_players_ids, action_types, action_amounts) fpdb_simple.storeActions(cursor, hands_players_ids, action_types, action_amounts)
return site_hand_no return site_hand_no
@ -40,7 +40,7 @@ def ring_stud(cursor, category, site_hand_no, gametype_id, hand_start_time,
#stores a holdem/omaha hand into the database #stores a holdem/omaha hand into the database
def ring_holdem_omaha(cursor, category, site_hand_no, gametype_id, hand_start_time, def ring_holdem_omaha(cursor, category, site_hand_no, gametype_id, hand_start_time,
names, player_ids, start_cashes, positions, card_values, card_suits, names, player_ids, start_cashes, positions, card_values, card_suits,
board_values, board_suits, winnings, rakes, action_types, action_amounts, hands_players_flags): board_values, board_suits, winnings, rakes, action_types, action_amounts, hudImportData):
#fill up the two player card arrays #fill up the two player card arrays
if (category=="holdem"): if (category=="holdem"):
fpdb_simple.fillCardArrays(len(names), 2, card_values, card_suits) fpdb_simple.fillCardArrays(len(names), 2, card_values, card_suits)
@ -56,7 +56,7 @@ def ring_holdem_omaha(cursor, category, site_hand_no, gametype_id, hand_start_ti
hands_players_ids=fpdb_simple.store_hands_players_holdem_omaha(cursor, category, hands_id, player_ids, hands_players_ids=fpdb_simple.store_hands_players_holdem_omaha(cursor, category, hands_id, player_ids,
start_cashes, positions, card_values, card_suits, winnings, rakes) start_cashes, positions, card_values, card_suits, winnings, rakes)
fpdb_simple.store_hands_players_flags(cursor, category, hands_players_ids, hands_players_flags) fpdb_simple.storeHudData(cursor, category, gametype_id, player_ids, hudImportData)
fpdb_simple.store_board_cards(cursor, hands_id, board_values, board_suits) fpdb_simple.store_board_cards(cursor, hands_id, board_values, board_suits)
@ -69,7 +69,7 @@ def tourney_holdem_omaha(cursor, category, site_tourney_no, buyin, fee, knockout
site_hand_no, site_id, gametype_id, hand_start_time, names, player_ids, site_hand_no, site_id, gametype_id, hand_start_time, names, player_ids,
start_cashes, positions, card_values, card_suits, start_cashes, positions, card_values, card_suits,
board_values, board_suits, winnings, rakes, board_values, board_suits, winnings, rakes,
action_types, action_amounts, hands_players_flags): action_types, action_amounts, hudImportData):
#stores a tourney stud/razz hand into the database #stores a tourney stud/razz hand into the database
#fill up the two player card arrays #fill up the two player card arrays
if (category=="holdem"): if (category=="holdem"):
@ -90,7 +90,7 @@ def tourney_holdem_omaha(cursor, category, site_tourney_no, buyin, fee, knockout
hands_players_ids=fpdb_simple.store_hands_players_holdem_omaha_tourney(cursor, hands_id, player_ids, hands_players_ids=fpdb_simple.store_hands_players_holdem_omaha_tourney(cursor, hands_id, player_ids,
start_cashes, positions, card_values, card_suits, winnings, rakes, tourneys_players_ids) start_cashes, positions, card_values, card_suits, winnings, rakes, tourneys_players_ids)
fpdb_simple.store_hands_players_flags(cursor, category, hands_players_ids, hands_players_flags) fpdb_simple.storeHudData(cursor, category, player_ids, hudImportData)
fpdb_simple.store_board_cards(cursor, hands_id, board_values, board_suits) fpdb_simple.store_board_cards(cursor, hands_id, board_values, board_suits)
@ -102,7 +102,7 @@ def tourney_stud(cursor, category, site_tourney_no, buyin, fee, knockout, entrie
tourney_start, payin_amounts, ranks, #end of tourney specific params tourney_start, payin_amounts, ranks, #end of tourney specific params
site_hand_no, site_id, gametype_id, hand_start_time, names, player_ids, site_hand_no, site_id, gametype_id, hand_start_time, names, player_ids,
start_cashes, antes, card_values, card_suits, winnings, rakes, start_cashes, antes, card_values, card_suits, winnings, rakes,
action_types, action_amounts, hands_players_flags): action_types, action_amounts, hudImportData):
#stores a tourney stud/razz hand into the database #stores a tourney stud/razz hand into the database
fpdb_simple.fillCardArrays(len(names), 7, card_values, card_suits) fpdb_simple.fillCardArrays(len(names), 7, card_values, card_suits)
@ -115,7 +115,7 @@ def tourney_stud(cursor, category, site_tourney_no, buyin, fee, knockout, entrie
hands_players_ids=fpdb_simple.store_hands_players_stud_tourney(cursor, hands_id, player_ids, hands_players_ids=fpdb_simple.store_hands_players_stud_tourney(cursor, hands_id, player_ids,
start_cashes, antes, card_values, card_suits, winnings, rakes, tourneys_players_ids) start_cashes, antes, card_values, card_suits, winnings, rakes, tourneys_players_ids)
fpdb_simple.store_hands_players_flags(cursor, category, hands_players_ids, hands_players_flags) fpdb_simple.storeHudData(cursor, category, player_ids, hudImportData)
fpdb_simple.storeActions(cursor, hands_players_ids, action_types, action_amounts) fpdb_simple.storeActions(cursor, hands_players_ids, action_types, action_amounts)
return site_hand_no return site_hand_no

View File

@ -1246,7 +1246,7 @@ def calculateHudImport(player_ids, category, action_types):
for count in range (len(action_types[street][player])):#finally individual actions for count in range (len(action_types[street][player])):#finally individual actions
currentAction=action_types[street][player][count] currentAction=action_types[street][player][count]
if currentAction!="bet": if currentAction!="bet":
pfRaiseCount++ pfRaiseCount+=1
if (currentAction=="bet" or currentAction=="call"): if (currentAction=="bet" or currentAction=="call"):
myVPIP=True myVPIP=True
if pfRaiseCount>=1: if pfRaiseCount>=1:
@ -1290,15 +1290,64 @@ def calculateHudImport(player_ids, category, action_types):
result['otherRaisedRiver']=otherRaisedRiver result['otherRaisedRiver']=otherRaisedRiver
result['otherRaisedRiverFold']=otherRaisedRiverFold result['otherRaisedRiverFold']=otherRaisedRiverFold
return result return result
#end def calculate_hands_players_flags #end def calculateHudImport
def store_hands_players_flags(cursor, category, hand_player_ids, hands_players_flags): def storeHudData(cursor, category, gametypeId, playerIds, hudImportData):
if (category=="holdem" or category=="omahahi" or category=="omahahilo"): if (category=="holdem" or category=="omahahi" or category=="omahahilo"):
for i in range (len(hand_player_ids)): for player in range (len(playerIds)):
cursor.execute("""INSERT INTO hands_players_flags (hand_player_id, folded_on, street0_vpi, street0_raise, street1_raise, street2_raise, street3_raise) VALUES (%s, %s, %s, %s, %s, %s, %s)""", (hand_player_ids[i], hands_players_flags['folded_on'][i], hands_players_flags['street0_vpi'][i], hands_players_flags['street0_raise'][i], hands_players_flags['street1_raise'][i], hands_players_flags['street2_raise'][i], hands_players_flags['street3_raise'][i])) cursor.execute("SELECT * FROM HudDataHoldemOmaha WHERE gametypeId=%s AND playerId=%s AND activeSeats=%s", (gametypeId, playerIds[player], len(playerIds)))
row=cursor.fetchone()
print "gametypeId:", gametypeId, "playerIds[player]",playerIds[player], "len(playerIds):",len(playerIds), "row:",row
try: len(row)
except TypeError:
row=[]
if (len(row)==0):
print "new huddata row"
doInsert=True
row=[]
row.append(0)#blank for id
row.append(gametypeId)
row.append(playerIds[player])
row.append(len(playerIds))#seats
row.append(0)#HDs
for i in range(len(hudImportData)):
row.append(0)
else: else:
for i in range (len(hand_player_ids)): doInsert=False
cursor.execute("""INSERT INTO hands_players_flags (hand_player_id, folded_on, street0_vpi, street0_raise, street1_raise, street2_raise, street3_raise, street4_raise) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)""", (hand_player_ids[i], hands_players_flags['folded_on'][i], hands_players_flags['street0_vpi'][i], hands_players_flags['street0_raise'][i], hands_players_flags['street1_raise'][i], hands_players_flags['street2_raise'][i], hands_players_flags['street3_raise'][i], hands_players_flags['street4_raise'][i])) newrow=[]
for i in range(len(row)):
newrow.append(row[i])
row=newrow
row[4]+=1 #HDs
if hudImportData['VPIP'][player]: row[5]+=1
if hudImportData['PFR'][player]: row[6]+=1
if hudImportData['PF3B4B'][player]: row[7]+=1
if hudImportData['sawFlop'][player]: row[8]+=1
if hudImportData['sawTurn'][player]: row[9]+=1
if hudImportData['sawRiver'][player]: row[10]+=1
if hudImportData['sawShowdown'][player]: row[11]+=1
if hudImportData['raisedFlop'][player]: row[12]+=1
if hudImportData['raisedTurn'][player]: row[13]+=1
if hudImportData['raisedRiver'][player]: row[14]+=1
if hudImportData['otherRaisedFlop'][player]: row[15]+=1
if hudImportData['otherRaisedFlopFold'][player]: row[16]+=1
if hudImportData['otherRaisedTurn'][player]: row[17]+=1
if hudImportData['otherRaisedTurnFold'][player]: row[18]+=1
if hudImportData['otherRaisedRiver'][player]: row[19]+=1
if hudImportData['otherRaisedRiverFold'][player]: row[20]+=1
if doInsert:
print "playerid before insert:",row[2]
cursor.execute("""INSERT INTO HudDataHoldemOmaha
(gametypeId, playerId, activeSeats, HDs, VPIP, PFR, PF3B4B, sawFlop, sawTurn, sawRiver, sawShowdown, raisedFlop, raisedTurn, raisedRiver, otherRaisedFlop, otherRaisedFlopFold, otherRaisedTurn, otherRaisedTurnFold, otherRaisedRiver, otherRaisedRiverFold)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""", (row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8], row[9], row[10], row[11], row[12], row[13], row[14], row[15], row[16], row[17], row[18], row[19], row[20]))
else:
print "todo: store updated line"
else:
raise FpdbError("todo")
#end def store_hands_players_flags(cursor, hands_players_ids, hands_players_flags) #end def store_hands_players_flags(cursor, hands_players_ids, hands_players_flags)
def store_tourneys(cursor, site_id, site_tourney_no, buyin, fee, knockout, entries, prizepool, start_time): def store_tourneys(cursor, site_id, site_tourney_no, buyin, fee, knockout, entries, prizepool, start_time):