* Updated the methods, variables, and SQL in Database.py and SQL.py to add Hours to the HudCache.styleKey field

This commit is contained in:
Chaz 2010-11-24 14:14:29 -06:00
parent 134d26855f
commit ac4cae5abf
2 changed files with 22 additions and 22 deletions

View File

@ -291,8 +291,8 @@ class Database:
# vars for hand ids or dates fetched according to above config:
self.hand_1day_ago = 0 # max hand id more than 24 hrs earlier than now
self.date_ndays_ago = 'd000000' # date N days ago ('d' + YYMMDD)
self.h_date_ndays_ago = 'd000000' # date N days ago ('d' + YYMMDD) for hero
self.date_ndays_ago = 'd00000000' # date N days ago ('d' + YYMMDD)
self.h_date_ndays_ago = 'd00000000' # date N days ago ('d' + YYMMDD) for hero
self.date_nhands_ago = {} # dates N hands ago per player - not used yet
self.saveActions = False if self.import_options['saveActions'] == False else True
@ -703,7 +703,7 @@ class Database:
try:
# self.date_nhands_ago is used for fetching stats for last n hands (hud_style = 'H')
# This option not used yet - needs to be called for each player :-(
self.date_nhands_ago[str(playerid)] = 'd000000'
self.date_nhands_ago[str(playerid)] = 'd00000000'
# should use aggregated version of query if appropriate
c.execute(self.sql.query['get_date_nhands_ago'], (self.hud_hands, playerid))
@ -771,11 +771,11 @@ class Database:
if hud_style == 'T':
stylekey = self.date_ndays_ago
elif hud_style == 'A':
stylekey = '0000000' # all stylekey values should be higher than this
stylekey = '000000000' # all stylekey values should be higher than this
elif hud_style == 'S':
stylekey = 'zzzzzzz' # all stylekey values should be lower than this
stylekey = 'zzzzzzzzz' # all stylekey values should be lower than this
else:
stylekey = '0000000'
stylekey = '000000000'
log.info('hud_style: %s' % hud_style)
#elif hud_style == 'H':
@ -784,11 +784,11 @@ class Database:
if h_hud_style == 'T':
h_stylekey = self.h_date_ndays_ago
elif h_hud_style == 'A':
h_stylekey = '0000000' # all stylekey values should be higher than this
h_stylekey = '000000000' # all stylekey values should be higher than this
elif h_hud_style == 'S':
h_stylekey = 'zzzzzzz' # all stylekey values should be lower than this
h_stylekey = 'zzzzzzzzz' # all stylekey values should be lower than this
else:
h_stylekey = '000000'
h_stylekey = '00000000'
log.info('h_hud_style: %s' % h_hud_style)
#elif h_hud_style == 'H':
@ -1824,11 +1824,11 @@ class Database:
"""Update cached statistics. If update fails because no record exists, do an insert."""
if self.use_date_in_hudcache:
styleKey = datetime.strftime(starttime, 'd%y%m%d')
#styleKey = "d%02d%02d%02d" % (hand_start_time.year-2000, hand_start_time.month, hand_start_time.day)
styleKey = datetime.strftime(starttime, 'd%y%m%d%h')
#styleKey = "d%02d%02d%02d%02d" % (hand_start_time.year-2000, hand_start_time.month, hand_start_time.day, hand_start_time.hour)
else:
# hard-code styleKey as 'A000000' (all-time cache, no key) for now
styleKey = 'A000000'
# hard-code styleKey as 'A00000000' (all-time cache, no key) for now
styleKey = 'A00000000'
update_hudcache = self.sql.query['update_hudcache']
update_hudcache = update_hudcache.replace('%s', self.sql.query['placeholder'])

View File

@ -2047,7 +2047,7 @@ class Sql:
# gets a date, would need to use handsplayers (not hudcache) to get exact hand Id
if db_server == 'mysql':
self.query['get_date_nhands_ago'] = """
select concat( 'd', date_format(max(h.startTime), '%Y%m%d') )
select concat( 'd', date_format(max(h.startTime), '%Y%m%d%h') )
from (select hp.playerId
,coalesce(greatest(max(hp.handId)-%s,1),1) as maxminusx
from HandsPlayers hp
@ -2059,7 +2059,7 @@ class Sql:
"""
elif db_server == 'postgresql':
self.query['get_date_nhands_ago'] = """
select 'd' || to_char(max(h3.startTime), 'YYMMDD')
select 'd' || to_char(max(h3.startTime), 'YYMMDDHH')
from (select hp.playerId
,coalesce(greatest(max(hp.handId)-%s,1),1) as maxminusx
from HandsPlayers hp
@ -2071,7 +2071,7 @@ class Sql:
"""
elif db_server == 'sqlite': # untested guess at query:
self.query['get_date_nhands_ago'] = """
select 'd' || strftime(max(h3.startTime), 'YYMMDD')
select 'd' || strftime(max(h3.startTime), 'YYMMDDHH')
from (select hp.playerId
,coalesce(greatest(max(hp.handId)-%s,1),1) as maxminusx
from HandsPlayers hp
@ -3290,7 +3290,7 @@ class Sql:
else 'E'
end AS hc_position
<tourney_select_clause>
,date_format(h.startTime, 'd%y%m%d')
,date_format(h.startTime, 'd%y%m%d%h')
,count(1)
,sum(wonWhenSeenStreet1)
,sum(wonWhenSeenStreet2)
@ -3379,7 +3379,7 @@ class Sql:
,h.seats
,hc_position
<tourney_group_clause>
,date_format(h.startTime, 'd%y%m%d')
,date_format(h.startTime, 'd%y%m%d%h')
"""
elif db_server == 'postgresql':
self.query['rebuildHudCache'] = """
@ -3488,7 +3488,7 @@ class Sql:
else 'E'
end AS hc_position
<tourney_select_clause>
,'d' || to_char(h.startTime, 'YYMMDD')
,'d' || to_char(h.startTime, 'YYMMDDHH')
,count(1)
,sum(wonWhenSeenStreet1)
,sum(wonWhenSeenStreet2)
@ -3577,7 +3577,7 @@ class Sql:
,h.seats
,hc_position
<tourney_group_clause>
,to_char(h.startTime, 'YYMMDD')
,to_char(h.startTime, 'YYMMDDHH')
"""
else: # assume sqlite
self.query['rebuildHudCache'] = """
@ -3686,7 +3686,7 @@ class Sql:
else 'E'
end AS hc_position
<tourney_select_clause>
,'d' || substr(strftime('%Y%m%d', h.startTime),3,7)
,'d' || substr(strftime('%Y%m%d%h', h.startTime),3,7)
,count(1)
,sum(wonWhenSeenStreet1)
,sum(wonWhenSeenStreet2)
@ -3775,7 +3775,7 @@ class Sql:
,h.seats
,hc_position
<tourney_group_clause>
,'d' || substr(strftime('%Y%m%d', h.startTime),3,7)
,'d' || substr(strftime('%Y%m%d%h', h.startTime),3,7)
"""
self.query['insert_hudcache'] = """