another intermediate commit for tourney stats

This commit is contained in:
steffen123 2010-07-10 06:23:47 +02:00
parent b1e41a54ec
commit 97fbc7606c
3 changed files with 69 additions and 66 deletions

View File

@ -321,7 +321,7 @@ class Filters(threading.Thread):
# get_text() returns a str but we want internal variables to be unicode: # get_text() returns a str but we want internal variables to be unicode:
_guiname = unicode(_name) _guiname = unicode(_name)
self.heroes[site] = _guiname self.heroes[site] = _guiname
# log.debug("setting heroes[%s]: %s"%(site, self.heroes[site])) #log.debug("setting heroes[%s]: %s"%(site, self.heroes[site]))
#end def __set_hero_name #end def __set_hero_name
def __set_num_hands(self, w, val): def __set_num_hands(self, w, val):

View File

@ -34,6 +34,7 @@ class GuiTourneyPlayerStats (threading.Thread):
def __init__(self, config, db, sql, mainwin, debug=True): def __init__(self, config, db, sql, mainwin, debug=True):
self.conf = config self.conf = config
self.db = db self.db = db
self.cursor = self.db.cursor
self.sql = sql self.sql = sql
self.main_window = mainwin self.main_window = mainwin
self.debug = debug self.debug = debug
@ -41,7 +42,7 @@ class GuiTourneyPlayerStats (threading.Thread):
self.liststore = [] # gtk.ListStore[] stores the contents of the grids self.liststore = [] # gtk.ListStore[] stores the contents of the grids
self.listcols = [] # gtk.TreeViewColumn[][] stores the columns in the grids self.listcols = [] # gtk.TreeViewColumn[][] stores the columns in the grids
filters_display = { "Heroes" : False, filters_display = { "Heroes" : True,
"Sites" : True, "Sites" : True,
#"Games" : True, #"Games" : True,
#"Limits" : True, #"Limits" : True,
@ -272,6 +273,7 @@ class GuiTourneyPlayerStats (threading.Thread):
for site in sites: for site in sites:
if sites[site] == True: if sites[site] == True:
sitenos.append(siteids[site]) sitenos.append(siteids[site])
print "heroes",heroes
_hname = Charset.to_utf8(heroes[site]) _hname = Charset.to_utf8(heroes[site])
result = self.db.get_player_id(self.conf, site, _hname) result = self.db.get_player_id(self.conf, site, _hname)
if result is not None: if result is not None:
@ -298,13 +300,16 @@ class GuiTourneyPlayerStats (threading.Thread):
holecards = flags[0] holecards = flags[0]
numTourneys = flags[1] numTourneys = flags[1]
#if 'allplayers' in groups and groups['allplayers']: if playerids:
nametest = "(hp.playerId)" nametest = str(tuple(playerids))
nametest = nametest.replace("L", "")
nametest = nametest.replace(",)",")")
else:
nametest = "1 = 2"
pname = "p.name" pname = "p.name"
# set flag in self.columns to show player name column # set flag in self.columns to not show player name column
[x for x in self.columns if x[0] == 'pname'][0][1] = True #[x for x in self.columns if x[0] == 'pname'][0][1] = False #TODO: fix and reactivate
if numTourneys:
having = ' and count(1) > %d ' % (numTourneys,)
query = query.replace("<player_test>", nametest) query = query.replace("<player_test>", nametest)
query = query.replace("<playerName>", pname) query = query.replace("<playerName>", pname)
query = query.replace("<havingclause>", having) query = query.replace("<havingclause>", having)
@ -355,53 +360,43 @@ class GuiTourneyPlayerStats (threading.Thread):
query = query.replace('<groupbyseats>', '') query = query.replace('<groupbyseats>', '')
query = query.replace('<orderbyseats>', '') query = query.replace('<orderbyseats>', '')
lims = [int(x) for x in limits if x.isdigit()] #lims = [int(x) for x in limits if x.isdigit()]
potlims = [int(x[0:-2]) for x in limits if len(x) > 2 and x[-2:] == 'pl'] #potlims = [int(x[0:-2]) for x in limits if len(x) > 2 and x[-2:] == 'pl']
nolims = [int(x[0:-2]) for x in limits if len(x) > 2 and x[-2:] == 'nl'] #nolims = [int(x[0:-2]) for x in limits if len(x) > 2 and x[-2:] == 'nl']
bbtest = "and ( (gt.limitType = 'fl' and gt.bigBlind in " #bbtest = "and ( (gt.limitType = 'fl' and gt.bigBlind in "
# and ( (limit and bb in()) or (nolimit and bb in ()) ) # and ( (limit and bb in()) or (nolimit and bb in ()) )
if lims: #if lims:
blindtest = str(tuple(lims)) # blindtest = str(tuple(lims))
blindtest = blindtest.replace("L", "") # blindtest = blindtest.replace("L", "")
blindtest = blindtest.replace(",)",")") # blindtest = blindtest.replace(",)",")")
bbtest = bbtest + blindtest + ' ) ' # bbtest = bbtest + blindtest + ' ) '
else: #else:
bbtest = bbtest + '(-1) ) ' # bbtest = bbtest + '(-1) ) '
bbtest = bbtest + " or (gt.limitType = 'pl' and gt.bigBlind in " #bbtest = bbtest + " or (gt.limitType = 'pl' and gt.bigBlind in "
if potlims: #if potlims:
blindtest = str(tuple(potlims)) # blindtest = str(tuple(potlims))
blindtest = blindtest.replace("L", "") # blindtest = blindtest.replace("L", "")
blindtest = blindtest.replace(",)",")") # blindtest = blindtest.replace(",)",")")
bbtest = bbtest + blindtest + ' ) ' # bbtest = bbtest + blindtest + ' ) '
else: #else:
bbtest = bbtest + '(-1) ) ' # bbtest = bbtest + '(-1) ) '
bbtest = bbtest + " or (gt.limitType = 'nl' and gt.bigBlind in " #bbtest = bbtest + " or (gt.limitType = 'nl' and gt.bigBlind in "
if nolims: #if nolims:
blindtest = str(tuple(nolims)) # blindtest = str(tuple(nolims))
blindtest = blindtest.replace("L", "") # blindtest = blindtest.replace("L", "")
blindtest = blindtest.replace(",)",")") # blindtest = blindtest.replace(",)",")")
bbtest = bbtest + blindtest + ' ) )' # bbtest = bbtest + blindtest + ' ) )'
else: #else:
bbtest = bbtest + '(-1) ) )' # bbtest = bbtest + '(-1) ) )'
if type == 'ring':
bbtest = bbtest + " and gt.type = 'ring' "
elif type == 'tour':
bbtest = " and gt.type = 'tour' "
query = query.replace("<gtbigBlind_test>", bbtest)
if holecards: # re-use level variables for hole card query #if type == 'ring':
query = query.replace("<hgameTypeId>", "hp.startcards") # bbtest = bbtest + " and gt.type = 'ring' "
query = query.replace("<orderbyhgameTypeId>" #elif type == 'tour':
, ",case when floor((hp.startcards-1)/13) >= mod((hp.startcards-1),13) then hp.startcards + 0.1 " #bbtest = " and gt.type = 'tour' "
+ " else 13*mod((hp.startcards-1),13) + floor((hp.startcards-1)/13) + 1 "
+ " end desc ") #query = query.replace("<gtbigBlind_test>", bbtest)
else:
query = query.replace("<orderbyhgameTypeId>", "") #query = query.replace("<orderbyhgameTypeId>", "")
groupLevels = "show" not in str(limits)
if groupLevels:
query = query.replace("<hgameTypeId>", "p.name") # need to use p.name for sqlite posn stats to work
else:
query = query.replace("<hgameTypeId>", "h.gameTypeId")
# process self.detailFilters (a list of tuples) # process self.detailFilters (a list of tuples)
flagtest = '' flagtest = ''
@ -414,7 +409,7 @@ class GuiTourneyPlayerStats (threading.Thread):
query = query.replace("<flagtest>", flagtest) query = query.replace("<flagtest>", flagtest)
# allow for differences in sql cast() function: # allow for differences in sql cast() function:
if self.db.backend == self.MYSQL_INNODB: if self.db.backend == self.db.MYSQL_INNODB:
query = query.replace("<signed>", 'signed ') query = query.replace("<signed>", 'signed ')
else: else:
query = query.replace("<signed>", '') query = query.replace("<signed>", '')
@ -423,17 +418,17 @@ class GuiTourneyPlayerStats (threading.Thread):
query = query.replace("<datestest>", " between '" + dates[0] + "' and '" + dates[1] + "'") query = query.replace("<datestest>", " between '" + dates[0] + "' and '" + dates[1] + "'")
# Group by position? # Group by position?
if groups['posn']: #if groups['posn']:
#query = query.replace("<position>", "case hp.position when '0' then 'Btn' else hp.position end") # #query = query.replace("<position>", "case hp.position when '0' then 'Btn' else hp.position end")
query = query.replace("<position>", "hp.position") # query = query.replace("<position>", "hp.position")
# set flag in self.columns to show posn column # # set flag in self.columns to show posn column
[x for x in self.columns if x[0] == 'plposition'][0][1] = True # [x for x in self.columns if x[0] == 'plposition'][0][1] = True
else: #else:
query = query.replace("<position>", "gt.base") # query = query.replace("<position>", "gt.base")
# unset flag in self.columns to hide posn column # # unset flag in self.columns to hide posn column
[x for x in self.columns if x[0] == 'plposition'][0][1] = False # [x for x in self.columns if x[0] == 'plposition'][0][1] = False
#print "query =\n", query print "query at end of refine query:", query
return(query) return(query)
#end def refineQuery #end def refineQuery

View File

@ -116,6 +116,14 @@ class TourneyFilters(threading.Thread):
self.make_filter() self.make_filter()
#end def __refresh #end def __refresh
def __set_hero_name(self, w, site):
_name = w.get_text()
# get_text() returns a str but we want internal variables to be unicode:
_guiname = unicode(_name)
self.heroes[site] = _guiname
#log.debug("setting heroes[%s]: %s"%(site, self.heroes[site]))
#end def __set_hero_name
def __set_num_tourneys(self, w, val): def __set_num_tourneys(self, w, val):
try: try:
self.numTourneys = int(w.get_text()) self.numTourneys = int(w.get_text())
@ -174,7 +182,7 @@ class TourneyFilters(threading.Thread):
_nt = (_n, ) _nt = (_n, )
liststore.append(_nt) liststore.append(_nt)
#self.__set_hero_name(pname, site) self.__set_hero_name(pname, site)
#end def createPlayerLine #end def createPlayerLine
def createSiteLine(self, hbox, site): def createSiteLine(self, hbox, site):