intermediate commit for tourney stats
This commit is contained in:
parent
4efd9dc2fb
commit
eb976203c4
|
@ -74,16 +74,17 @@ class GuiTourneyPlayerStats (threading.Thread):
|
||||||
# columns to display, keys match column name returned by sql, values in tuple are:
|
# columns to display, keys match column name returned by sql, values in tuple are:
|
||||||
# is column displayed, column heading, xalignment, formatting, celltype
|
# is column displayed, column heading, xalignment, formatting, celltype
|
||||||
self.columns = [ ["tourneyTypeId", True, "TTypeId", 0.0, "%s", "str"]
|
self.columns = [ ["tourneyTypeId", True, "TTypeId", 0.0, "%s", "str"]
|
||||||
, ["tourney", False, "Tourney", 0.0, "%s", "str"] # true not allowed for this line
|
#, ["tourney", False, "Tourney", 0.0, "%s", "str"] # true not allowed for this line
|
||||||
#, ["pname", False, "Name", 0.0, "%s", "str"] # true not allowed for this line (set in code)
|
, ["playerName", False, "Name", 0.0, "%s", "str"] # true not allowed for this line (set in code)
|
||||||
, ["tourneyCount", True, "#", 1.0, "%1.0f", "str"]
|
, ["tourneyCount", True, "#", 1.0, "%1.0f", "str"]
|
||||||
, ["1st", False, "1st", 1.0, "%3.1f", "str"]
|
, ["1st", False, "1st", 1.0, "%3.1f", "str"]
|
||||||
, ["2nd", True, "2nd", 1.0, "%3.1f", "str"]
|
, ["2nd", True, "2nd", 1.0, "%3.1f", "str"]
|
||||||
, ["3rd", True, "3rd", 1.0, "%3.1f", "str"]
|
, ["3rd", True, "3rd", 1.0, "%3.1f", "str"]
|
||||||
, ["unknownRank", True, "unknown", 1.0, "%3.1f", "str"]
|
, ["unknownRank", True, "unknown", 1.0, "%3.1f", "str"]
|
||||||
, ["itm", True, "ITM", 1.0, "%2.2f", "str"]
|
#, ["itm", True, "ITM", 1.0, "%2.2f", "str"]
|
||||||
, ["roi", True, "ROI", 1.0, "%3.1f", "str"]
|
#, ["roi", True, "ROI", 1.0, "%3.1f", "str"]
|
||||||
, ["profitPerTourney", True, "$/T", 1.0, "%3.1f", "str"]]
|
, ["invested", True, "Invested", 1.0, "%3.1f", "str"]
|
||||||
|
, ["profit", True, "Profit", 1.0, "%3.1f", "str"]]
|
||||||
|
|
||||||
self.stats_frame = gtk.Frame()
|
self.stats_frame = gtk.Frame()
|
||||||
self.stats_frame.show()
|
self.stats_frame.show()
|
||||||
|
@ -100,16 +101,15 @@ class GuiTourneyPlayerStats (threading.Thread):
|
||||||
self.main_hbox.show()
|
self.main_hbox.show()
|
||||||
#end def __init__
|
#end def __init__
|
||||||
|
|
||||||
def addGrid(self, vbox, query, flags, tourneyTypes, playerids, sitenos, seats, dates):
|
def addGrid(self, vbox, query, numTourneys, tourneyTypes, playerids, sitenos, seats, dates):
|
||||||
|
print "start of addGrid query", query
|
||||||
counter = 0
|
counter = 0
|
||||||
row = 0
|
row = 0
|
||||||
sqlrow = 0
|
sqlrow = 0
|
||||||
if not flags: holecards,grid = False,0
|
|
||||||
else: holecards,grid = flags[0],flags[2]
|
query = self.sql.query[query]
|
||||||
|
query = self.refineQuery(query, numTourneys, tourneyTypes, playerids, sitenos, seats, dates)
|
||||||
tmp = self.sql.query[query]
|
self.cursor.execute(query)
|
||||||
tmp = self.refineQuery(tmp, flags, tourneyTypes, playerids, sitenos, seats, dates)
|
|
||||||
self.cursor.execute(tmp)
|
|
||||||
result = self.cursor.fetchall()
|
result = self.cursor.fetchall()
|
||||||
colnames = [desc[0].lower() for desc in self.cursor.description]
|
colnames = [desc[0].lower() for desc in self.cursor.description]
|
||||||
|
|
||||||
|
@ -221,13 +221,8 @@ class GuiTourneyPlayerStats (threading.Thread):
|
||||||
swin.show()
|
swin.show()
|
||||||
vbox.pack1(swin)
|
vbox.pack1(swin)
|
||||||
|
|
||||||
# Display summary table at top of page
|
numTourneys = self.filters.getNumTourneys()
|
||||||
# 3rd parameter passes extra flags, currently includes:
|
self.addGrid(swin, 'tourneyPlayerDetailedStats', numTourneys, tourneyTypes, playerids
|
||||||
# holecards - whether to display card breakdown (True/False)
|
|
||||||
# numhands - min number hands required when displaying all players
|
|
||||||
# gridnum - index for grid data structures
|
|
||||||
flags = [False, self.filters.getNumTourneys(), 0]
|
|
||||||
self.addGrid(swin, 'playerDetailedStats', flags, tourneyTypes, playerids
|
|
||||||
,sitenos, seats, dates)
|
,sitenos, seats, dates)
|
||||||
|
|
||||||
if 'allplayers' in groups and groups['allplayers']:
|
if 'allplayers' in groups and groups['allplayers']:
|
||||||
|
@ -295,41 +290,42 @@ class GuiTourneyPlayerStats (threading.Thread):
|
||||||
return self.main_hbox
|
return self.main_hbox
|
||||||
#end def get_vbox
|
#end def get_vbox
|
||||||
|
|
||||||
def refineQuery(self, query, flags, tourneyTypes, playerids, sitenos, seats, dates):
|
def refineQuery(self, query, numTourneys, tourneyTypes, playerids, sitenos, seats, dates):
|
||||||
having = ''
|
having = ''
|
||||||
holecards = flags[0]
|
|
||||||
numTourneys = flags[1]
|
print "start of refinequery, playerids:",playerids
|
||||||
|
|
||||||
if playerids:
|
if playerids:
|
||||||
nametest = str(tuple(playerids))
|
nametest = str(tuple(playerids))
|
||||||
nametest = nametest.replace("L", "")
|
nametest = nametest.replace("L", "")
|
||||||
nametest = nametest.replace(",)",")")
|
nametest = nametest.replace(",)",")")
|
||||||
else:
|
else:
|
||||||
nametest = "1 = 2"
|
nametest = "1 = 2"
|
||||||
|
print "refinequery, nametest after initial creation:",nametest
|
||||||
pname = "p.name"
|
pname = "p.name"
|
||||||
# set flag in self.columns to not 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] = False #TODO: fix and reactivate
|
#[x for x in self.columns if x[0] == 'pname'][0][1] = False #TODO: fix and reactivate
|
||||||
|
|
||||||
query = query.replace("<player_test>", nametest)
|
query = query.replace("<nametest>", nametest)
|
||||||
query = query.replace("<playerName>", pname)
|
query = query.replace("<playerName>", pname)
|
||||||
query = query.replace("<havingclause>", having)
|
query = query.replace("<havingclause>", having)
|
||||||
|
|
||||||
gametest = ""
|
#TODO: remove, or replace with tourneytest
|
||||||
q = []
|
#gametest = ""
|
||||||
for m in self.filters.display.items():
|
#q = []
|
||||||
if m[0] == 'Games' and m[1]:
|
#for m in self.filters.display.items():
|
||||||
for n in games:
|
# if m[0] == 'Games' and m[1]:
|
||||||
if games[n]:
|
# for n in games:
|
||||||
q.append(n)
|
# if games[n]:
|
||||||
if len(q) > 0:
|
# q.append(n)
|
||||||
gametest = str(tuple(q))
|
# if len(q) > 0:
|
||||||
gametest = gametest.replace("L", "")
|
# gametest = str(tuple(q))
|
||||||
gametest = gametest.replace(",)",")")
|
# gametest = gametest.replace("L", "")
|
||||||
gametest = gametest.replace("u'","'")
|
# gametest = gametest.replace(",)",")")
|
||||||
gametest = "and gt.category in %s" % gametest
|
# gametest = gametest.replace("u'","'")
|
||||||
else:
|
# gametest = "and gt.category in %s" % gametest
|
||||||
gametest = "and gt.category IS NULL"
|
# else:
|
||||||
query = query.replace("<game_test>", gametest)
|
# gametest = "and gt.category IS NULL"
|
||||||
|
#query = query.replace("<game_test>", gametest)
|
||||||
|
|
||||||
sitetest = ""
|
sitetest = ""
|
||||||
q = []
|
q = []
|
||||||
|
@ -342,10 +338,11 @@ class GuiTourneyPlayerStats (threading.Thread):
|
||||||
sitetest = sitetest.replace("L", "")
|
sitetest = sitetest.replace("L", "")
|
||||||
sitetest = sitetest.replace(",)",")")
|
sitetest = sitetest.replace(",)",")")
|
||||||
sitetest = sitetest.replace("u'","'")
|
sitetest = sitetest.replace("u'","'")
|
||||||
sitetest = "and gt.siteId in %s" % sitetest
|
sitetest = "and tt.siteId in %s" % sitetest#[1:-1]
|
||||||
else:
|
else:
|
||||||
sitetest = "and gt.siteId IS NULL"
|
sitetest = "and tt.siteId IS NULL"
|
||||||
query = query.replace("<site_test>", sitetest)
|
print "refinequery, sitetest before its use for replacement:",sitetest
|
||||||
|
query = query.replace("<sitetest>", sitetest)
|
||||||
|
|
||||||
if seats:
|
if seats:
|
||||||
query = query.replace('<seats_test>', 'between ' + str(seats['from']) + ' and ' + str(seats['to']))
|
query = query.replace('<seats_test>', 'between ' + str(seats['from']) + ' and ' + str(seats['to']))
|
||||||
|
|
|
@ -2257,6 +2257,29 @@ class Sql:
|
||||||
,s.name
|
,s.name
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if db_server == 'mysql':
|
||||||
|
self.query['tourneyPlayerDetailedStats'] = """
|
||||||
|
select t.tourneyTypeId AS tourneyTypeId
|
||||||
|
,p.name AS playerName
|
||||||
|
,s.name AS siteName
|
||||||
|
,sum(t.winnings)/100.0 AS profit
|
||||||
|
,sum(t.buyin+t.fee)/100.0 AS invested
|
||||||
|
from TourneysPlayers tp
|
||||||
|
inner join Tourneys t on (t.id = tp.tourneyId)
|
||||||
|
inner join TourneyTypes tt on (tt.Id = t.tourneyTypeId)
|
||||||
|
inner join Sites s on (s.Id = gt.siteId)
|
||||||
|
inner join Players p on (p.Id = tp.playerId)
|
||||||
|
where tp.playerId in <nametest> <sitetest>
|
||||||
|
and date_format(t.startTime, '%Y-%m-%d %T') <datestest>
|
||||||
|
group by tourneyTypeId, playerName
|
||||||
|
order by tourneyTypeId
|
||||||
|
,pname
|
||||||
|
,s.name"""
|
||||||
|
elif db_server == 'postgresql':
|
||||||
|
self.query['tourneyPlayerDetailedStats'] = """TODO"""
|
||||||
|
elif db_server == 'sqlite':
|
||||||
|
self.query['tourneyPlayerDetailedStats'] = """TODO"""
|
||||||
|
|
||||||
if db_server == 'mysql':
|
if db_server == 'mysql':
|
||||||
self.query['playerStats'] = """
|
self.query['playerStats'] = """
|
||||||
SELECT
|
SELECT
|
||||||
|
|
Loading…
Reference in New Issue
Block a user