storeSessionsCache() now adds a sessionId to the Hands table
This commit is contained in:
parent
838c626bba
commit
990e226254
|
@ -73,7 +73,7 @@ except ImportError:
|
|||
use_numpy = False
|
||||
|
||||
|
||||
DB_VERSION = 148
|
||||
DB_VERSION = 149
|
||||
|
||||
|
||||
# Variance created as sqlite has a bunch of undefined aggregate functions.
|
||||
|
@ -1718,10 +1718,11 @@ class Database:
|
|||
|
||||
c.execute(q, (
|
||||
p['tableName'],
|
||||
p['gametypeId'],
|
||||
p['siteHandNo'],
|
||||
p['tourneyId'],
|
||||
p['startTime'],
|
||||
p['gametypeId'],
|
||||
p['sessionId'],
|
||||
p['startTime'],
|
||||
datetime.utcnow(), #importtime
|
||||
p['seats'],
|
||||
p['maxSeats'],
|
||||
|
@ -2035,10 +2036,9 @@ class Database:
|
|||
pass
|
||||
|
||||
def storeSessionsCache(self, pids, startTime, game, pdata):
|
||||
"""Update cached sessions. If update fails because no record exists, do an insert"""
|
||||
"""Update cached sessions. If no record exists, do an insert"""
|
||||
|
||||
THRESHOLD = timedelta(seconds=int(self.sessionTimeout * 60))
|
||||
bigBet = int(Decimal(game['bb'])*200)
|
||||
|
||||
select_sessionscache = self.sql.query['select_sessionscache']
|
||||
select_sessionscache = select_sessionscache.replace('%s', self.sql.query['placeholder'])
|
||||
|
@ -2061,6 +2061,9 @@ class Database:
|
|||
delete_sessions = self.sql.query['delete_sessions']
|
||||
delete_sessions = delete_sessions.replace('%s', self.sql.query['placeholder'])
|
||||
|
||||
update_hands_sessionid = self.sql.query['update_hands_sessionid']
|
||||
update_hands_sessionid = update_hands_sessionid.replace('%s', self.sql.query['placeholder'])
|
||||
|
||||
#Grab playerIds using hero names in HUD_Config.xml
|
||||
try:
|
||||
# derive list of program owner's player ids
|
||||
|
@ -2090,30 +2093,35 @@ class Database:
|
|||
|
||||
if (game['type']=='ring'): line[0] = 1 # count ring hands
|
||||
if (game['type']=='tour'): line[1] = 1 # count tour hands
|
||||
if (game['type']=='ring'): line[2] = pdata[p]['totalProfit'] #sum of profit
|
||||
if (game['type']=='ring'): line[3] = 0 #float(Decimal(pdata[p]['totalProfit'])/Decimal(bigBet)) #sum of big bets won
|
||||
if (game['type']=='ring' and game['currency']=='USD'): line[2] = pdata[p]['totalProfit'] #sum of ring profit in USD
|
||||
if (game['type']=='ring' and game['currency']=='EUR'): line[3] = pdata[p]['totalProfit'] #sum of ring profit in EUR
|
||||
line[4] = startTime
|
||||
inserts.append(line)
|
||||
|
||||
cursor = self.get_cursor()
|
||||
id = None
|
||||
|
||||
for row in inserts:
|
||||
threshold = []
|
||||
session_records = []
|
||||
threshold.append(row[-1]-THRESHOLD)
|
||||
threshold.append(row[-1]+THRESHOLD)
|
||||
cursor.execute(select_sessionscache, threshold)
|
||||
num = cursor.rowcount
|
||||
for r in cursor:
|
||||
if r: session_records.append(r[0])
|
||||
num = len(session_records)
|
||||
if (num == 1):
|
||||
id = session_records[0] #grab the sessionId
|
||||
# Try to do the update first:
|
||||
#print "DEBUG: found 1 record to update"
|
||||
update_mid = row + row[-1:]
|
||||
cursor.execute(select_sessionscache_mid, update_mid[-2:])
|
||||
mid = cursor.rowcount
|
||||
if (mid == 0):
|
||||
mid = cursor.fetchone()
|
||||
if mid:
|
||||
update_startend = row[-1:] + row + threshold
|
||||
cursor.execute(select_sessionscache_start, update_startend[-3:])
|
||||
start = cursor.rowcount
|
||||
if (start == 0):
|
||||
start = cursor.fetchone()
|
||||
if start:
|
||||
#print "DEBUG:", start, " start record found. Update stats and start time"
|
||||
cursor.execute(update_sessionscache_end, update_startend)
|
||||
else:
|
||||
|
@ -2123,37 +2131,36 @@ class Database:
|
|||
#print "DEBUG: update stats mid-session"
|
||||
cursor.execute(update_sessionscache_mid, update_mid)
|
||||
elif (num > 1):
|
||||
session_ids = [session_records[0][0], session_records[1][0]]
|
||||
session_ids.sort()
|
||||
# Multiple matches found - merge them into one session and update:
|
||||
#print "DEBUG:", num, "matches found"
|
||||
cursor.execute(merge_sessionscache, threshold)
|
||||
# - Obtain the session start and end times for the new combined session
|
||||
cursor.execute(merge_sessionscache, session_ids)
|
||||
merge = cursor.fetchone()
|
||||
cursor.execute(delete_sessions, threshold)
|
||||
# - Delete the old records
|
||||
for id in session_ids:
|
||||
cursor.execute(delete_sessions, id)
|
||||
# - Insert the new updated record
|
||||
cursor.execute(insert_sessionscache, merge)
|
||||
# - Obtain the new sessionId and write over the old ids in Hands
|
||||
id = self.get_last_insert_id(cursor) #grab the sessionId
|
||||
update_hands = [id] + session_ids
|
||||
cursor.execute(update_hands_sessionid, update_hands)
|
||||
# - Update the newly combined record in SessionsCache with data from this hand
|
||||
update_mid = row + row[-1:]
|
||||
cursor.execute(select_sessionscache_mid, update_mid[-2:])
|
||||
mid = cursor.rowcount
|
||||
if (mid == 0):
|
||||
update_startend = row[-1:] + row + threshold
|
||||
cursor.execute(select_sessionscache_start, update_startend[-3:])
|
||||
start = cursor.rowcount
|
||||
if (start == 0):
|
||||
#print "DEBUG:", start, " start record found. Update stats and start time"
|
||||
cursor.execute(update_sessionscache_end, update_startend)
|
||||
else:
|
||||
#print "DEBUG: 1 end record found. Update stats and end time time"
|
||||
cursor.execute(update_sessionscache_start, update_startend)
|
||||
else:
|
||||
#print "DEBUG: update stats mid-session"
|
||||
cursor.execute(update_sessionscache_mid, update_mid)
|
||||
cursor.execute(update_sessionscache_mid, update_mid)
|
||||
elif (num == 0):
|
||||
# No matches found, insert new session:
|
||||
insert = row + row[-1:]
|
||||
insert = insert[-2:] + insert[:-2]
|
||||
#print "DEBUG: No matches found. Insert record", insert
|
||||
cursor.execute(insert_sessionscache, insert)
|
||||
id = self.get_last_insert_id(cursor) #grab the sessionId
|
||||
else:
|
||||
# Something bad happened
|
||||
pass
|
||||
pass
|
||||
|
||||
return id
|
||||
|
||||
def isDuplicate(self, gametypeID, siteHandNo):
|
||||
dup = False
|
||||
|
|
|
@ -102,6 +102,7 @@ class DerivedStats():
|
|||
self.hands['tableName'] = hand.tablename
|
||||
self.hands['siteHandNo'] = hand.handid
|
||||
self.hands['gametypeId'] = None # Leave None, handled later after checking db
|
||||
self.hands['sessionId'] = None # Leave None, added later if caching sessions
|
||||
self.hands['startTime'] = hand.startTime # format this!
|
||||
self.hands['importTime'] = None
|
||||
self.hands['seats'] = self.countPlayers(hand)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
<FreePokerToolsConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FreePokerToolsConfig.xsd">
|
||||
|
||||
<import callFpdbHud = "True" interval = "10" fastStoreHudCache="False" hhArchiveBase="~/.fpdb/HandHistories/" saveActions="True" cacheSessions="True" sessionTimeout="30"></import>
|
||||
<import callFpdbHud = "True" interval = "10" fastStoreHudCache="False" hhArchiveBase="~/.fpdb/HandHistories/" saveActions="True" cacheSessions="False" sessionTimeout="30"></import>
|
||||
|
||||
<!-- These values determine what stats are displayed in the HUD
|
||||
|
||||
|
@ -211,7 +211,7 @@ Left-Drag to Move"
|
|||
</layout>
|
||||
</site>
|
||||
|
||||
<site enabled="False"
|
||||
<site enabled="True"
|
||||
site_name="Everleaf"
|
||||
table_finder="Everleaf.exe"
|
||||
screen_name="Hero"
|
||||
|
@ -255,7 +255,7 @@ Left-Drag to Move"
|
|||
</layout>
|
||||
</site>
|
||||
|
||||
<site enabled="False"
|
||||
<site enabled="True"
|
||||
site_name="Win2day"
|
||||
table_finder="Win2day.exe"
|
||||
screen_name="Hero"
|
||||
|
@ -300,7 +300,7 @@ Left-Drag to Move"
|
|||
</site>
|
||||
|
||||
|
||||
<site enabled="False"
|
||||
<site enabled="True"
|
||||
site_name="Absolute"
|
||||
table_finder="AbsolutePoker.exe"
|
||||
screen_name="Hero"
|
||||
|
@ -345,7 +345,7 @@ Left-Drag to Move"
|
|||
</site>
|
||||
|
||||
|
||||
<site enabled="False"
|
||||
<site enabled="True"
|
||||
site_name="PartyPoker"
|
||||
table_finder="PartyGaming.exe"
|
||||
screen_name="Hero"
|
||||
|
@ -390,7 +390,7 @@ Left-Drag to Move"
|
|||
</site>
|
||||
|
||||
|
||||
<site enabled="False"
|
||||
<site enabled="True"
|
||||
site_name="Betfair"
|
||||
table_finder="Betfair Poker.exe"
|
||||
screen_name="Hero"
|
||||
|
@ -433,6 +433,188 @@ Left-Drag to Move"
|
|||
<location seat="9" x="70" y="53"> </location>
|
||||
</layout>
|
||||
</site>
|
||||
|
||||
|
||||
<site HH_path="C:/Program Files/Carbon Poker/HandHistory/Hero/" converter="CarbonToFpdb" decoder="everleaf_decode_table" enabled="True" screen_name="Hero" site_name="Carbon" site_path="C:/Program Files/Carbin/" supported_games="holdem" table_finder="Carbon Poker.exe">
|
||||
<layout fav_seat="0" height="547" max="8" width="794">
|
||||
<location seat="1" x="640" y="64"> </location>
|
||||
<location seat="2" x="650" y="230"> </location>
|
||||
<location seat="3" x="650" y="385"> </location>
|
||||
<location seat="4" x="588" y="425"> </location>
|
||||
<location seat="5" x="92" y="425"> </location>
|
||||
<location seat="6" x="0" y="373"> </location>
|
||||
<location seat="7" x="0" y="223"> </location>
|
||||
<location seat="8" x="25" y="50"> </location>
|
||||
</layout>
|
||||
<layout fav_seat="0" height="547" max="6" width="794">
|
||||
<location seat="1" x="640" y="58"> </location>
|
||||
<location seat="2" x="654" y="288"> </location>
|
||||
<location seat="3" x="615" y="424"> </location>
|
||||
<location seat="4" x="70" y="421"> </location>
|
||||
<location seat="5" x="0" y="280"> </location>
|
||||
<location seat="6" x="70" y="58"> </location>
|
||||
</layout>
|
||||
<layout fav_seat="0" height="547" max="2" width="794">
|
||||
<location seat="1" x="651" y="288"> </location>
|
||||
<location seat="2" x="10" y="288"> </location>
|
||||
</layout>
|
||||
<layout fav_seat="0" height="547" max="9" width="794">
|
||||
<location seat="1" x="634" y="38"> </location>
|
||||
<location seat="2" x="667" y="184"> </location>
|
||||
<location seat="3" x="667" y="321"> </location>
|
||||
<location seat="4" x="667" y="445"> </location>
|
||||
<location seat="5" x="337" y="459"> </location>
|
||||
<location seat="6" x="0" y="400"> </location>
|
||||
<location seat="7" x="0" y="322"> </location>
|
||||
<location seat="8" x="0" y="181"> </location>
|
||||
<location seat="9" x="70" y="53"> </location>
|
||||
</layout>
|
||||
</site>
|
||||
|
||||
<site HH_path="C:/Program Files/OnGame Sking/HandHistory/Hero/" converter="OnGameToFpdb" decoder="everleaf_decode_table" enabled="True" screen_name="Hero" site_name="OnGame" site_path="C:/Program Files/OnGame/" supported_games="holdem" table_finder="OnGame.exe">
|
||||
<layout fav_seat="0" height="547" max="8" width="794">
|
||||
<location seat="1" x="640" y="64"> </location>
|
||||
<location seat="2" x="650" y="230"> </location>
|
||||
<location seat="3" x="650" y="385"> </location>
|
||||
<location seat="4" x="588" y="425"> </location>
|
||||
<location seat="5" x="92" y="425"> </location>
|
||||
<location seat="6" x="0" y="373"> </location>
|
||||
<location seat="7" x="0" y="223"> </location>
|
||||
<location seat="8" x="25" y="50"> </location>
|
||||
</layout>
|
||||
<layout fav_seat="0" height="547" max="6" width="794">
|
||||
<location seat="1" x="640" y="58"> </location>
|
||||
<location seat="2" x="654" y="288"> </location>
|
||||
<location seat="3" x="615" y="424"> </location>
|
||||
<location seat="4" x="70" y="421"> </location>
|
||||
<location seat="5" x="0" y="280"> </location>
|
||||
<location seat="6" x="70" y="58"> </location>
|
||||
</layout>
|
||||
<layout fav_seat="0" height="547" max="2" width="794">
|
||||
<location seat="1" x="651" y="288"> </location>
|
||||
<location seat="2" x="10" y="288"> </location>
|
||||
</layout>
|
||||
<layout fav_seat="0" height="547" max="9" width="794">
|
||||
<location seat="1" x="634" y="38"> </location>
|
||||
<location seat="2" x="667" y="184"> </location>
|
||||
<location seat="3" x="667" y="321"> </location>
|
||||
<location seat="4" x="667" y="445"> </location>
|
||||
<location seat="5" x="337" y="459"> </location>
|
||||
<location seat="6" x="0" y="400"> </location>
|
||||
<location seat="7" x="0" y="322"> </location>
|
||||
<location seat="8" x="0" y="181"> </location>
|
||||
<location seat="9" x="70" y="53"> </location>
|
||||
</layout>
|
||||
</site>
|
||||
|
||||
<site HH_path="C:/Program Files/PKR/HandHistory/Hero/" converter="PkrToFpdb" decoder="everleaf_decode_table" enabled="True" screen_name="Hero" site_name="PKR" site_path="C:/Program Files/PKR/" supported_games="holdem" table_finder="PKR.exe">
|
||||
<layout fav_seat="0" height="547" max="8" width="794">
|
||||
<location seat="1" x="640" y="64"> </location>
|
||||
<location seat="2" x="650" y="230"> </location>
|
||||
<location seat="3" x="650" y="385"> </location>
|
||||
<location seat="4" x="588" y="425"> </location>
|
||||
<location seat="5" x="92" y="425"> </location>
|
||||
<location seat="6" x="0" y="373"> </location>
|
||||
<location seat="7" x="0" y="223"> </location>
|
||||
<location seat="8" x="25" y="50"> </location>
|
||||
</layout>
|
||||
<layout fav_seat="0" height="547" max="6" width="794">
|
||||
<location seat="1" x="640" y="58"> </location>
|
||||
<location seat="2" x="654" y="288"> </location>
|
||||
<location seat="3" x="615" y="424"> </location>
|
||||
<location seat="4" x="70" y="421"> </location>
|
||||
<location seat="5" x="0" y="280"> </location>
|
||||
<location seat="6" x="70" y="58"> </location>
|
||||
</layout>
|
||||
<layout fav_seat="0" height="547" max="2" width="794">
|
||||
<location seat="1" x="651" y="288"> </location>
|
||||
<location seat="2" x="10" y="288"> </location>
|
||||
</layout>
|
||||
<layout fav_seat="0" height="547" max="9" width="794">
|
||||
<location seat="1" x="634" y="38"> </location>
|
||||
<location seat="2" x="667" y="184"> </location>
|
||||
<location seat="3" x="667" y="321"> </location>
|
||||
<location seat="4" x="667" y="445"> </location>
|
||||
<location seat="5" x="337" y="459"> </location>
|
||||
<location seat="6" x="0" y="400"> </location>
|
||||
<location seat="7" x="0" y="322"> </location>
|
||||
<location seat="8" x="0" y="181"> </location>
|
||||
<location seat="9" x="70" y="53"> </location>
|
||||
</layout>
|
||||
</site>
|
||||
|
||||
<site HH_path="C:/Program Files/iPoker/HandHistory/Hero/" converter="iPokerToFpdb" decoder="everleaf_decode_table" enabled="True" screen_name="Hero" site_name="iPoker" site_path="C:/Program Files/iPoker/" supported_games="holdem" table_finder="iPoker.exe">
|
||||
<layout fav_seat="0" height="547" max="8" width="794">
|
||||
<location seat="1" x="640" y="64"> </location>
|
||||
<location seat="2" x="650" y="230"> </location>
|
||||
<location seat="3" x="650" y="385"> </location>
|
||||
<location seat="4" x="588" y="425"> </location>
|
||||
<location seat="5" x="92" y="425"> </location>
|
||||
<location seat="6" x="0" y="373"> </location>
|
||||
<location seat="7" x="0" y="223"> </location>
|
||||
<location seat="8" x="25" y="50"> </location>
|
||||
</layout>
|
||||
<layout fav_seat="0" height="547" max="6" width="794">
|
||||
<location seat="1" x="640" y="58"> </location>
|
||||
<location seat="2" x="654" y="288"> </location>
|
||||
<location seat="3" x="615" y="424"> </location>
|
||||
<location seat="4" x="70" y="421"> </location>
|
||||
<location seat="5" x="0" y="280"> </location>
|
||||
<location seat="6" x="70" y="58"> </location>
|
||||
</layout>
|
||||
<layout fav_seat="0" height="547" max="2" width="794">
|
||||
<location seat="1" x="651" y="288"> </location>
|
||||
<location seat="2" x="10" y="288"> </location>
|
||||
</layout>
|
||||
<layout fav_seat="0" height="547" max="9" width="794">
|
||||
<location seat="1" x="634" y="38"> </location>
|
||||
<location seat="2" x="667" y="184"> </location>
|
||||
<location seat="3" x="667" y="321"> </location>
|
||||
<location seat="4" x="667" y="445"> </location>
|
||||
<location seat="5" x="337" y="459"> </location>
|
||||
<location seat="6" x="0" y="400"> </location>
|
||||
<location seat="7" x="0" y="322"> </location>
|
||||
<location seat="8" x="0" y="181"> </location>
|
||||
<location seat="9" x="70" y="53"> </location>
|
||||
</layout>
|
||||
</site>
|
||||
|
||||
<site HH_path="C:/Program Files/Winamax/HandHistory/Hero/" converter="WinamaxToFpdb" decoder="everleaf_decode_table" enabled="True" screen_name="Hero" site_name="Winamax" site_path="C:/Program Files/Winamax/" supported_games="holdem" table_finder="Winamax.exe">
|
||||
<layout fav_seat="0" height="547" max="8" width="794">
|
||||
<location seat="1" x="640" y="64"> </location>
|
||||
<location seat="2" x="650" y="230"> </location>
|
||||
<location seat="3" x="650" y="385"> </location>
|
||||
<location seat="4" x="588" y="425"> </location>
|
||||
<location seat="5" x="92" y="425"> </location>
|
||||
<location seat="6" x="0" y="373"> </location>
|
||||
<location seat="7" x="0" y="223"> </location>
|
||||
<location seat="8" x="25" y="50"> </location>
|
||||
</layout>
|
||||
<layout fav_seat="0" height="547" max="6" width="794">
|
||||
<location seat="1" x="640" y="58"> </location>
|
||||
<location seat="2" x="654" y="288"> </location>
|
||||
<location seat="3" x="615" y="424"> </location>
|
||||
<location seat="4" x="70" y="421"> </location>
|
||||
<location seat="5" x="0" y="280"> </location>
|
||||
<location seat="6" x="70" y="58"> </location>
|
||||
</layout>
|
||||
<layout fav_seat="0" height="547" max="2" width="794">
|
||||
<location seat="1" x="651" y="288"> </location>
|
||||
<location seat="2" x="10" y="288"> </location>
|
||||
</layout>
|
||||
<layout fav_seat="0" height="547" max="9" width="794">
|
||||
<location seat="1" x="634" y="38"> </location>
|
||||
<location seat="2" x="667" y="184"> </location>
|
||||
<location seat="3" x="667" y="321"> </location>
|
||||
<location seat="4" x="667" y="445"> </location>
|
||||
<location seat="5" x="337" y="459"> </location>
|
||||
<location seat="6" x="0" y="400"> </location>
|
||||
<location seat="7" x="0" y="322"> </location>
|
||||
<location seat="8" x="0" y="181"> </location>
|
||||
<location seat="9" x="70" y="53"> </location>
|
||||
</layout>
|
||||
</site>
|
||||
|
||||
</supported_sites>
|
||||
|
||||
<supported_games>
|
||||
|
|
|
@ -57,6 +57,7 @@ class Hand(object):
|
|||
#log.debug( _("Hand.init(): handText is ") + str(handText) )
|
||||
self.config = config
|
||||
self.saveActions = self.config.get_import_parameters().get('saveActions')
|
||||
self.cacheSessions = self.config.get_import_parameters().get("cacheSessions")
|
||||
#log = Configuration.get_logger("logging.conf", "db", log_dir=self.config.dir_log)
|
||||
self.sitename = sitename
|
||||
self.siteId = self.config.get_site_id(sitename)
|
||||
|
@ -264,9 +265,15 @@ db: a connected Database object"""
|
|||
hh['gametypeId'] = self.dbid_gt
|
||||
# seats TINYINT NOT NULL,
|
||||
hh['seats'] = len(self.dbid_pids)
|
||||
|
||||
hp = self.stats.getHandsPlayers()
|
||||
|
||||
if self.cacheSessions:
|
||||
hh['sessionId'] = db.storeSessionsCache(self.dbid_pids, self.startTime, self.gametype, hp)
|
||||
|
||||
self.dbid_hands = db.storeHand(hh, printdata = printtest)
|
||||
db.storeHandsPlayers(self.dbid_hands, self.dbid_pids, self.stats.getHandsPlayers(),
|
||||
|
||||
db.storeHandsPlayers(self.dbid_hands, self.dbid_pids, hp,
|
||||
printdata = printtest)
|
||||
if self.saveActions:
|
||||
db.storeHandsActions(self.dbid_hands, self.dbid_pids, self.stats.getHandsActions(),
|
||||
|
|
|
@ -346,6 +346,7 @@ class Sql:
|
|||
siteHandNo BIGINT NOT NULL,
|
||||
tourneyId INT UNSIGNED,
|
||||
gametypeId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
|
||||
sessionId INT UNSIGNED,
|
||||
startTime DATETIME NOT NULL,
|
||||
importTime DATETIME NOT NULL,
|
||||
seats TINYINT NOT NULL,
|
||||
|
@ -383,6 +384,7 @@ class Sql:
|
|||
siteHandNo BIGINT NOT NULL,
|
||||
tourneyId INT,
|
||||
gametypeId INT NOT NULL, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
|
||||
sessionId INT,
|
||||
startTime timestamp without time zone NOT NULL,
|
||||
importTime timestamp without time zone NOT NULL,
|
||||
seats SMALLINT NOT NULL,
|
||||
|
@ -419,6 +421,7 @@ class Sql:
|
|||
siteHandNo INT NOT NULL,
|
||||
tourneyId INT,
|
||||
gametypeId INT NOT NULL,
|
||||
sessionId INT,
|
||||
startTime REAL NOT NULL,
|
||||
importTime REAL NOT NULL,
|
||||
seats INT NOT NULL,
|
||||
|
@ -1368,8 +1371,8 @@ class Sql:
|
|||
sessionEnd DATETIME NOT NULL,
|
||||
ringHDs INT NOT NULL,
|
||||
tourHDs INT NOT NULL,
|
||||
totalProfit INT NOT NULL,
|
||||
bigBets FLOAT UNSIGNED NOT NULL)
|
||||
ringProfitUSD INT NOT NULL,
|
||||
ringProfitEUR INT NOT NULL)
|
||||
|
||||
ENGINE=INNODB"""
|
||||
elif db_server == 'postgresql':
|
||||
|
@ -1379,8 +1382,8 @@ class Sql:
|
|||
sessionEnd REAL NOT NULL,
|
||||
ringHDs INT NOT NULL,
|
||||
tourHDs INT NOT NULL,
|
||||
totalProfit INT NOT NULL,
|
||||
bigBets FLOAT NOT NULL)
|
||||
ringProfitUSD INT NOT NULL,
|
||||
ringProfitEUR INT NOT NULL)
|
||||
"""
|
||||
elif db_server == 'sqlite':
|
||||
self.query['createSessionsCacheTable'] = """CREATE TABLE SessionsCache (
|
||||
|
@ -1389,8 +1392,8 @@ class Sql:
|
|||
sessionEnd REAL NOT NULL,
|
||||
ringHDs INT NOT NULL,
|
||||
tourHDs INT NOT NULL,
|
||||
totalProfit INT NOT NULL,
|
||||
bigBets REAL UNSIGNED NOT NULL)
|
||||
ringProfitUSD INT NOT NULL,
|
||||
ringProfitEUR INT NOT NULL)
|
||||
"""
|
||||
|
||||
if db_server == 'mysql':
|
||||
|
@ -4058,12 +4061,13 @@ class Sql:
|
|||
####################################
|
||||
|
||||
self.query['select_sessionscache'] = """
|
||||
SELECT sessionStart,
|
||||
SELECT id,
|
||||
sessionStart,
|
||||
sessionEnd,
|
||||
ringHDs,
|
||||
tourHDs,
|
||||
totalProfit,
|
||||
bigBets
|
||||
ringProfitUSD,
|
||||
ringProfitEUR
|
||||
FROM SessionsCache
|
||||
WHERE sessionEnd>=%s
|
||||
AND sessionStart<=%s"""
|
||||
|
@ -4073,8 +4077,8 @@ class Sql:
|
|||
sessionEnd,
|
||||
ringHDs,
|
||||
tourHDs,
|
||||
totalProfit,
|
||||
bigBets
|
||||
ringProfitUSD,
|
||||
ringProfitEUR
|
||||
FROM SessionsCache
|
||||
WHERE sessionEnd>=%s
|
||||
AND sessionStart<=%s"""
|
||||
|
@ -4084,8 +4088,8 @@ class Sql:
|
|||
sessionEnd,
|
||||
ringHDs,
|
||||
tourHDs,
|
||||
totalProfit,
|
||||
bigBets
|
||||
ringProfitUSD,
|
||||
ringProfitEUR
|
||||
FROM SessionsCache
|
||||
WHERE sessionStart>%s
|
||||
AND sessionEnd>=%s
|
||||
|
@ -4095,8 +4099,8 @@ class Sql:
|
|||
UPDATE SessionsCache SET
|
||||
ringHDs=ringHDs+%s,
|
||||
tourHDs=tourHDs+%s,
|
||||
totalProfit=totalProfit+%s,
|
||||
bigBets=bigBets+%s
|
||||
ringProfitUSD=ringProfitUSD+%s,
|
||||
ringProfitEUR=ringProfitEUR+%s
|
||||
WHERE sessionStart<=%s
|
||||
AND sessionEnd>=%s"""
|
||||
|
||||
|
@ -4105,8 +4109,8 @@ class Sql:
|
|||
sessionStart=%s,
|
||||
ringHDs=ringHDs+%s,
|
||||
tourHDs=tourHDs+%s,
|
||||
totalProfit=totalProfit+%s,
|
||||
bigBets=bigBets+%s
|
||||
ringProfitUSD=ringProfitUSD+%s,
|
||||
ringProfitEUR=ringProfitEUR+%s
|
||||
WHERE sessionStart>%s
|
||||
AND sessionEnd>=%s
|
||||
AND sessionStart<=%s"""
|
||||
|
@ -4116,8 +4120,8 @@ class Sql:
|
|||
sessionEnd=%s,
|
||||
ringHDs=ringHDs+%s,
|
||||
tourHDs=tourHDs+%s,
|
||||
totalProfit=totalProfit+%s,
|
||||
bigBets=bigBets+%s
|
||||
ringProfitUSD=ringProfitUSD+%s,
|
||||
ringProfitEUR=ringProfitEUR+%s
|
||||
WHERE sessionEnd<%s
|
||||
AND sessionEnd>=%s
|
||||
AND sessionStart<=%s"""
|
||||
|
@ -4128,20 +4132,27 @@ class Sql:
|
|||
sessionEnd,
|
||||
ringHDs,
|
||||
tourHDs,
|
||||
totalProfit,
|
||||
bigBets)
|
||||
ringProfitUSD,
|
||||
ringProfitEUR)
|
||||
VALUES (%s, %s, %s, %s, %s, %s)"""
|
||||
|
||||
self.query['merge_sessionscache'] = """
|
||||
SELECT min(sessionStart), max(sessionEnd), sum(ringHDs), sum(tourHDs), sum(totalProfit), sum(bigBets)
|
||||
SELECT min(sessionStart), max(sessionEnd), sum(ringHDs), sum(tourHDs), sum(ringProfitUSD), sum(ringProfitEUR)
|
||||
FROM SessionsCache
|
||||
WHERE sessionEnd>=%s
|
||||
AND sessionStart<=%s"""
|
||||
WHERE (case when id=%s or id=%s then 1 else 0 end)=1"""
|
||||
|
||||
self.query['delete_sessions'] = """
|
||||
DELETE FROM SessionsCache
|
||||
WHERE sessionEnd>=%s
|
||||
AND sessionStart<=%s"""
|
||||
WHERE id=%s"""
|
||||
|
||||
self.query['update_hands_sessionid'] = """
|
||||
UPDATE Hands SET
|
||||
sessionId=%s
|
||||
WHERE (case when sessionId=%s or sessionId=%s then 1 else 0 end)=1"""
|
||||
|
||||
####################################
|
||||
# Database management queries
|
||||
####################################
|
||||
|
||||
if db_server == 'mysql':
|
||||
self.query['analyze'] = """
|
||||
|
@ -4326,9 +4337,10 @@ class Sql:
|
|||
|
||||
self.query['store_hand'] = """insert into Hands (
|
||||
tablename,
|
||||
gametypeid,
|
||||
sitehandno,
|
||||
tourneyId,
|
||||
gametypeid,
|
||||
sessionId,
|
||||
startTime,
|
||||
importtime,
|
||||
seats,
|
||||
|
@ -4357,9 +4369,9 @@ class Sql:
|
|||
showdownPot
|
||||
)
|
||||
values
|
||||
(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s,
|
||||
%s, %s, %s, %s, %s, %s, %s, %s, %s, %s,
|
||||
%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)"""
|
||||
(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,
|
||||
%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,
|
||||
%s, %s, %s, %s, %s, %s, %s, %s, %s)"""
|
||||
|
||||
|
||||
self.query['store_hands_players'] = """insert into HandsPlayers (
|
||||
|
|
4
pyfpdb/TestHandsPlayers.py
Executable file → Normal file
4
pyfpdb/TestHandsPlayers.py
Executable file → Normal file
|
@ -115,14 +115,14 @@ def compare_hands_file(filename, importer, errors):
|
|||
pass
|
||||
else:
|
||||
# Stats don't match.
|
||||
if datum == "gametypeId":
|
||||
if datum == "gametypeId" or datum == 'sessionId':
|
||||
# Not an error. gametypeIds are dependent on the order added to the db.
|
||||
#print "DEBUG: Skipping mismatched gamtypeId"
|
||||
pass
|
||||
else:
|
||||
errors.error_report(filename, hand, datum, ghash, testhash, None)
|
||||
except KeyError, e:
|
||||
errors.error_report(filename, False, "KeyError: '%s'" % stat, False, False, p)
|
||||
errors.error_report(filename, False, "KeyError: '%s'" % datum, False, False, None)
|
||||
|
||||
|
||||
def compare(leaf, importer, errors, site):
|
||||
|
|
|
@ -83,7 +83,6 @@ class Importer:
|
|||
self.pos_in_file = {} # dict to remember how far we have read in the file
|
||||
#Set defaults
|
||||
self.callHud = self.config.get_import_parameters().get("callFpdbHud")
|
||||
self.cacheSessions = self.config.get_import_parameters().get("cacheSessions")
|
||||
|
||||
# CONFIGURATION OPTIONS
|
||||
self.settings.setdefault("minPrint", 30)
|
||||
|
@ -495,13 +494,6 @@ class Importer:
|
|||
if hand is not None and not hand.is_duplicate:
|
||||
hand.updateHudCache(self.database)
|
||||
self.database.commit()
|
||||
|
||||
# Call sessionsCache update
|
||||
if self.cacheSessions:
|
||||
for hand in handlist:
|
||||
if hand is not None and not hand.is_duplicate:
|
||||
hand.updateSessionsCache(self.database)
|
||||
self.database.commit()
|
||||
|
||||
#pipe the Hands.id out to the HUD
|
||||
if self.caller:
|
||||
|
|
Loading…
Reference in New Issue
Block a user