From 6d292c50d9e7c49f212e8c136b2ad4b47fef6e94 Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 15 Mar 2009 17:40:01 -0400 Subject: [PATCH] Use saveActions and fastStoreHudCache in fpdb_import, etc. --- pyfpdb/fpdb_import.py | 2 +- pyfpdb/fpdb_parse_logic.py | 10 +++--- pyfpdb/fpdb_save_to_db.py | 71 ++++++++++++++++++++++++++++++++++---- 3 files changed, 71 insertions(+), 12 deletions(-) diff --git a/pyfpdb/fpdb_import.py b/pyfpdb/fpdb_import.py index ef0894e3..12575b4f 100644 --- a/pyfpdb/fpdb_import.py +++ b/pyfpdb/fpdb_import.py @@ -352,7 +352,7 @@ class Importer: try: handsId=fpdb_parse_logic.mainParser(self.settings['db-backend'], self.fdb.db - ,self.fdb.cursor, site, category, hand) + ,self.fdb.cursor, site, category, hand, self.config) self.fdb.db.commit() stored+=1 diff --git a/pyfpdb/fpdb_parse_logic.py b/pyfpdb/fpdb_parse_logic.py index dab3bcc4..9dd54f83 100644 --- a/pyfpdb/fpdb_parse_logic.py +++ b/pyfpdb/fpdb_parse_logic.py @@ -21,7 +21,7 @@ import fpdb_simple import fpdb_save_to_db #parses a holdem hand -def mainParser(backend, db, cursor, site, category, hand): +def mainParser(backend, db, cursor, site, category, hand, config): category=fpdb_simple.recogniseCategory(hand[0]) if (category=="holdem" or category=="omahahi" or category=="omahahilo"): base="hold" @@ -150,7 +150,7 @@ def mainParser(backend, db, cursor, site, category, hand): if base=="hold": result = fpdb_save_to_db.tourney_holdem_omaha( - backend, db, cursor, base, category, siteTourneyNo, buyin + config, backend, db, cursor, base, category, siteTourneyNo, buyin , fee, knockout, entries, prizepool, tourneyStartTime , payin_amounts, ranks, tourneyTypeId, siteID, siteHandNo , gametypeID, handStartTime, names, playerIDs, startCashes @@ -159,7 +159,7 @@ def mainParser(backend, db, cursor, site, category, hand): , actionNos, hudImportData, maxSeats, tableName, seatNos) elif base=="stud": result = fpdb_save_to_db.tourney_stud( - backend, db, cursor, base, category, siteTourneyNo + config, backend, db, cursor, base, category, siteTourneyNo , buyin, fee, knockout, entries, prizepool, tourneyStartTime , payin_amounts, ranks, tourneyTypeId, siteID, siteHandNo , gametypeID, handStartTime, names, playerIDs, startCashes @@ -171,7 +171,7 @@ def mainParser(backend, db, cursor, site, category, hand): else: if base=="hold": result = fpdb_save_to_db.ring_holdem_omaha( - backend, db, cursor, base, category, siteHandNo + config, backend, db, cursor, base, category, siteHandNo , gametypeID, handStartTime, names, playerIDs , startCashes, positions, cardValues, cardSuits , boardValues, boardSuits, winnings, rakes @@ -179,7 +179,7 @@ def mainParser(backend, db, cursor, site, category, hand): , hudImportData, maxSeats, tableName, seatNos) elif base=="stud": result = fpdb_save_to_db.ring_stud( - backend, db, cursor, base, category, siteHandNo, gametypeID + config, backend, db, cursor, base, category, siteHandNo, gametypeID , handStartTime, names, playerIDs, startCashes, antes , cardValues, cardSuits, winnings, rakes, actionTypes, allIns , actionAmounts, actionNos, hudImportData, maxSeats, tableName diff --git a/pyfpdb/fpdb_save_to_db.py b/pyfpdb/fpdb_save_to_db.py index ba734e80..a656ec00 100644 --- a/pyfpdb/fpdb_save_to_db.py +++ b/pyfpdb/fpdb_save_to_db.py @@ -26,18 +26,29 @@ MYSQL_INNODB=2 PGSQL=3 SQLITE=4 -fastStoreHudCache=False # set this to True to test the new storeHudCache routine +fastStoreHudCache=True # set this to True to test the new storeHudCache routine -saveActions=True # set this to False to avoid storing action data +saveActions=False # set this to False to avoid storing action data # Pros: speeds up imports # Cons: no action data is saved, so you need to keep the hand histories # variance not available on stats page #stores a stud/razz hand into the database -def ring_stud(backend, db, cursor, base, category, site_hand_no, gametype_id, hand_start_time +def ring_stud(config, backend, db, cursor, base, category, site_hand_no, gametype_id, hand_start_time ,names, player_ids, start_cashes, antes, card_values, card_suits, winnings, rakes ,action_types, allIns, action_amounts, actionNos, hudImportData, maxSeats, tableName ,seatNos): + + import_options = config.get_import_parameters() + if import_options['saveActions'] == 'True': + saveActions = True + else: + saveActions = False + if import_options['fastStoreHudCache'] == 'True': + fastStoreHudCache = True + else: + fastStoreHudCache = False + fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits) hands_id=fpdb_simple.storeHands(backend, db, cursor, site_hand_no, gametype_id @@ -56,11 +67,27 @@ def ring_stud(backend, db, cursor, base, category, site_hand_no, gametype_id, ha return hands_id #end def ring_stud -def ring_holdem_omaha(backend, db, cursor, base, category, site_hand_no, gametype_id +def ring_holdem_omaha(config, backend, db, cursor, base, 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, allIns ,action_amounts, actionNos, hudImportData, maxSeats, tableName, seatNos): """stores a holdem/omaha hand into the database""" + + import_options = config.get_import_parameters() + if import_options['saveActions'] == 'True': + saveActions = True + else: + saveActions = False + if import_options['fastStoreHudCache'] == 'True': + fastStoreHudCache = True + else: + fastStoreHudCache = False + + fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits) + + hands_id=fpdb_simple.storeHands(backend, db, cursor, site_hand_no, gametype_id + ,hand_start_time, names, tableName, maxSeats) + t0 = time() fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits) t1 = time() @@ -89,7 +116,7 @@ def ring_holdem_omaha(backend, db, cursor, base, category, site_hand_no, gametyp return hands_id #end def ring_holdem_omaha -def tourney_holdem_omaha(backend, db, cursor, base, category, siteTourneyNo, buyin, fee, knockout +def tourney_holdem_omaha(config, backend, db, cursor, base, category, siteTourneyNo, buyin, fee, knockout ,entries, prizepool, tourney_start, payin_amounts, ranks, tourneyTypeId ,siteId #end of tourney specific params ,site_hand_no, gametype_id, hand_start_time, names, player_ids @@ -97,6 +124,22 @@ def tourney_holdem_omaha(backend, db, cursor, base, category, siteTourneyNo, buy ,board_suits, winnings, rakes, action_types, allIns, action_amounts ,actionNos, hudImportData, maxSeats, tableName, seatNos): """stores a tourney holdem/omaha hand into the database""" + + import_options = config.get_import_parameters() + if import_options['saveActions'] == 'True': + saveActions = True + else: + saveActions = False + if import_options['fastStoreHudCache'] == 'True': + fastStoreHudCache = True + else: + fastStoreHudCache = False + + fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits) + + hands_id=fpdb_simple.storeHands(backend, db, cursor, site_hand_no, gametype_id + ,hand_start_time, names, tableName, maxSeats) + fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits) fpdb_simple.fill_board_cards(board_values, board_suits) @@ -123,12 +166,28 @@ def tourney_holdem_omaha(backend, db, cursor, base, category, siteTourneyNo, buy return hands_id #end def tourney_holdem_omaha -def tourney_stud(backend, db, cursor, base, category, siteTourneyNo, buyin, fee, knockout, entries +def tourney_stud(config, backend, db, cursor, base, category, siteTourneyNo, buyin, fee, knockout, entries ,prizepool, tourneyStartTime, payin_amounts, ranks, tourneyTypeId, siteId ,siteHandNo, gametypeId, handStartTime, names, playerIds, startCashes, antes ,cardValues, cardSuits, winnings, rakes, actionTypes, allIns, actionAmounts ,actionNos, hudImportData, maxSeats, tableName, seatNos): #stores a tourney stud/razz hand into the database + + import_options = config.get_import_parameters() + if import_options['saveActions'] == 'True': + saveActions = True + else: + saveActions = False + if import_options['fastStoreHudCache'] == 'True': + fastStoreHudCache = True + else: + fastStoreHudCache = False + + fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits) + + hands_id=fpdb_simple.storeHands(backend, db, cursor, site_hand_no, gametype_id + ,hand_start_time, names, tableName, maxSeats) + fpdb_simple.fillCardArrays(len(names), base, category, cardValues, cardSuits) tourney_id=fpdb_simple.store_tourneys(cursor, tourneyTypeId, siteTourneyNo, entries, prizepool, tourneyStartTime)