diff --git a/docs/known-bugs-and-planned-features.txt b/docs/known-bugs-and-planned-features.txt index 51d6f7a2..178db304 100644 --- a/docs/known-bugs-and-planned-features.txt +++ b/docs/known-bugs-and-planned-features.txt @@ -3,10 +3,13 @@ todolist (db=database, imp=importer, tv=tableviewer) before beta =========== 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 -tv doesnt display street 3-5 in stud/razz i think +change save_to_db into one method and probably move into parse_logic +fix load profile 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 make a quick benchmark of mysql and postgresql: import of my whole db, some tableviewer refreshes with and without updated file diff --git a/prepare-git.sh b/prepare-git.sh index 44007d5f..7865c4f9 100755 --- a/prepare-git.sh +++ b/prepare-git.sh @@ -17,5 +17,5 @@ rm testdata/*.found.txt rm utils/*.pyc -rm fpdb-python/*.pyc +rm pyfpdb/*.pyc git-add--interactive diff --git a/pyfpdb/fpdb.py b/pyfpdb/fpdb.py index 2645c7b1..b0bc8f58 100755 --- a/pyfpdb/fpdb.py +++ b/pyfpdb/fpdb.py @@ -159,7 +159,7 @@ class fpdb: def dia_load_profile(self, widget, data): """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", action=gtk.FILE_CHOOSER_ACTION_OPEN, buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK)) diff --git a/pyfpdb/fpdb_parse_logic.py b/pyfpdb/fpdb_parse_logic.py index 6dc57212..b7aad5d5 100644 --- a/pyfpdb/fpdb_parse_logic.py +++ b/pyfpdb/fpdb_parse_logic.py @@ -113,7 +113,7 @@ def mainParser(db, cursor, site, category, hand): limit_type=cursor.fetchone()[0] #todo: remove this unnecessary database access 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: 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, siteHandNo, siteID, gametypeID, handStartTime, names, playerIDs, 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"): result = fpdb_save_to_db.tourney_stud(cursor, category, siteTourneyNo, buyin, fee, knockout, entries, prizepool, tourneyStartTime, payin_amounts, ranks, siteHandNo, siteID, gametypeID, handStartTime, names, playerIDs, startCashes, antes, cardValues, cardSuits, winnings, rakes, - actionTypes, actionAmounts, hands_players_flags) + actionTypes, actionAmounts, hudImportData) else: if (category=="holdem" or category=="omahahi" or category=="omahahilo"): result = fpdb_save_to_db.ring_holdem_omaha(cursor, category, siteHandNo, gametypeID, 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"): result = fpdb_save_to_db.ring_stud(cursor, category, siteHandNo, gametypeID, handStartTime, names, playerIDs, startCashes, antes, cardValues, - cardSuits, winnings, rakes, actionTypes, actionAmounts, hands_players_flags) + cardSuits, winnings, rakes, actionTypes, actionAmounts, hudImportData) else: raise fpdb_simple.FpdbError ("unrecognised category") db.commit() diff --git a/pyfpdb/fpdb_save_to_db.py b/pyfpdb/fpdb_save_to_db.py index 990ae09c..1dd656bf 100644 --- a/pyfpdb/fpdb_save_to_db.py +++ b/pyfpdb/fpdb_save_to_db.py @@ -23,7 +23,7 @@ import fpdb_simple #stores a stud/razz hand into the database def ring_stud(cursor, category, site_hand_no, gametype_id, hand_start_time, 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) 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, 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) 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 def ring_holdem_omaha(cursor, category, site_hand_no, gametype_id, hand_start_time, 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 if (category=="holdem"): 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, 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) @@ -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, start_cashes, positions, card_values, card_suits, 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 #fill up the two player card arrays 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, 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) @@ -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 site_hand_no, site_id, gametype_id, hand_start_time, names, player_ids, 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 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, 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) return site_hand_no diff --git a/pyfpdb/fpdb_simple.py b/pyfpdb/fpdb_simple.py index a18918fe..34240bad 100644 --- a/pyfpdb/fpdb_simple.py +++ b/pyfpdb/fpdb_simple.py @@ -1246,7 +1246,7 @@ def calculateHudImport(player_ids, category, action_types): for count in range (len(action_types[street][player])):#finally individual actions currentAction=action_types[street][player][count] if currentAction!="bet": - pfRaiseCount++ + pfRaiseCount+=1 if (currentAction=="bet" or currentAction=="call"): myVPIP=True if pfRaiseCount>=1: @@ -1290,15 +1290,64 @@ def calculateHudImport(player_ids, category, action_types): result['otherRaisedRiver']=otherRaisedRiver result['otherRaisedRiverFold']=otherRaisedRiverFold 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"): - for i in range (len(hand_player_ids)): - 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])) + for player in range (len(playerIds)): + 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: + doInsert=False + 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: - for i in range (len(hand_player_ids)): - 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])) + raise FpdbError("todo") #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):