2010-07-09 04:47:33 +02:00
|
|
|
#!/usr/bin/python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
#Copyright 2010 Steffen Schaumburg
|
|
|
|
#This program is free software: you can redistribute it and/or modify
|
|
|
|
#it under the terms of the GNU Affero General Public License as published by
|
|
|
|
#the Free Software Foundation, version 3 of the License.
|
|
|
|
#
|
|
|
|
#This program is distributed in the hope that it will be useful,
|
|
|
|
#but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
#GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
#You should have received a copy of the GNU Affero General Public License
|
|
|
|
#along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#In the "official" distribution you can find the license in agpl-3.0.txt.
|
|
|
|
|
|
|
|
#import traceback
|
2010-07-10 02:09:58 +02:00
|
|
|
import threading
|
|
|
|
import pygtk
|
|
|
|
pygtk.require('2.0')
|
|
|
|
import gtk
|
2010-07-09 04:47:33 +02:00
|
|
|
#import os
|
|
|
|
#import sys
|
2010-07-10 05:19:50 +02:00
|
|
|
from time import time, strftime
|
2010-07-09 04:47:33 +02:00
|
|
|
|
|
|
|
#import Card
|
|
|
|
#import fpdb_import
|
|
|
|
#import Database
|
2010-07-10 05:19:50 +02:00
|
|
|
import Charset
|
2010-07-10 02:09:58 +02:00
|
|
|
import TourneyFilters
|
|
|
|
|
2010-07-11 03:13:58 +02:00
|
|
|
colalias,colshow,colheading,colxalign,colformat,coltype = 0,1,2,3,4,5
|
|
|
|
|
2010-07-10 02:09:58 +02:00
|
|
|
class GuiTourneyPlayerStats (threading.Thread):
|
|
|
|
def __init__(self, config, db, sql, mainwin, debug=True):
|
|
|
|
self.conf = config
|
|
|
|
self.db = db
|
2010-07-10 06:23:47 +02:00
|
|
|
self.cursor = self.db.cursor
|
2010-07-10 02:09:58 +02:00
|
|
|
self.sql = sql
|
|
|
|
self.main_window = mainwin
|
|
|
|
self.debug = debug
|
|
|
|
|
|
|
|
self.liststore = [] # gtk.ListStore[] stores the contents of the grids
|
|
|
|
self.listcols = [] # gtk.TreeViewColumn[][] stores the columns in the grids
|
|
|
|
|
2010-07-10 06:23:47 +02:00
|
|
|
filters_display = { "Heroes" : True,
|
2010-07-10 02:09:58 +02:00
|
|
|
"Sites" : True,
|
|
|
|
#"Games" : True,
|
|
|
|
#"Limits" : True,
|
|
|
|
#"LimitSep" : True,
|
|
|
|
#"LimitType" : True,
|
|
|
|
#"Type" : True,
|
|
|
|
"Seats" : True,
|
|
|
|
#"SeatSep" : True,
|
|
|
|
"Dates" : True,
|
|
|
|
#"Groups" : True,
|
|
|
|
#"GroupsAll" : True,
|
|
|
|
#"Button1" : True,
|
|
|
|
"Button2" : True}
|
|
|
|
|
|
|
|
self.stats_frame = None
|
|
|
|
self.stats_vbox = None
|
|
|
|
self.detailFilters = [] # the data used to enhance the sql select
|
|
|
|
|
|
|
|
self.main_hbox = gtk.HPaned()
|
|
|
|
|
|
|
|
self.filters = TourneyFilters.TourneyFilters(self.db, self.conf, self.sql, display = filters_display)
|
|
|
|
#self.filters.registerButton1Name("_Filters")
|
|
|
|
#self.filters.registerButton1Callback(self.showDetailFilter)
|
|
|
|
self.filters.registerButton2Name("_Refresh Stats")
|
|
|
|
self.filters.registerButton2Callback(self.refreshStats)
|
2010-07-10 05:19:50 +02:00
|
|
|
|
|
|
|
# ToDo: store in config
|
|
|
|
# ToDo: create popup to adjust column config
|
|
|
|
# columns to display, keys match column name returned by sql, values in tuple are:
|
|
|
|
# is column displayed, column heading, xalignment, formatting, celltype
|
2010-07-11 04:47:15 +02:00
|
|
|
self.columns = [ ["siteName", True, "Site", 0.0, "%s", "str"]
|
2010-07-10 22:24:32 +02:00
|
|
|
#, ["tourney", False, "Tourney", 0.0, "%s", "str"] # true not allowed for this line
|
2010-07-11 04:47:15 +02:00
|
|
|
, ["buyIn", True, "BuyIn", 1.0, "%3.2f", "str"]
|
2010-07-10 22:24:32 +02:00
|
|
|
, ["playerName", False, "Name", 0.0, "%s", "str"] # true not allowed for this line (set in code)
|
2010-07-10 05:19:50 +02:00
|
|
|
, ["tourneyCount", True, "#", 1.0, "%1.0f", "str"]
|
2010-07-11 05:11:43 +02:00
|
|
|
, ["itm", True, "ITM%", 1.0, "%3.2f", "str"]
|
2010-07-11 04:59:31 +02:00
|
|
|
, ["1st", False, "1st", 1.0, "%1.0f", "str"]
|
|
|
|
, ["2nd", True, "2nd", 1.0, "%1.0f", "str"]
|
|
|
|
, ["3rd", True, "3rd", 1.0, "%1.0f", "str"]
|
|
|
|
, ["unknownRank", True, "unknown", 1.0, "%1.0f", "str"]
|
2010-07-11 05:22:36 +02:00
|
|
|
, ["spent", True, "Spent", 1.0, "%3.2f", "str"]
|
|
|
|
, ["won", True, "Won", 1.0, "%3.2f", "str"]
|
|
|
|
, ["roi", True, "ROI%", 1.0, "%3.0f", "str"]]
|
|
|
|
|
2010-07-10 02:09:58 +02:00
|
|
|
self.stats_frame = gtk.Frame()
|
|
|
|
self.stats_frame.show()
|
|
|
|
|
|
|
|
self.stats_vbox = gtk.VPaned()
|
|
|
|
self.stats_vbox.show()
|
|
|
|
self.stats_frame.add(self.stats_vbox)
|
|
|
|
# self.fillStatsFrame(self.stats_vbox)
|
|
|
|
|
|
|
|
#self.main_hbox.pack_start(self.filters.get_vbox())
|
|
|
|
#self.main_hbox.pack_start(self.stats_frame, expand=True, fill=True)
|
|
|
|
self.main_hbox.pack1(self.filters.get_vbox())
|
|
|
|
self.main_hbox.pack2(self.stats_frame)
|
|
|
|
self.main_hbox.show()
|
|
|
|
#end def __init__
|
|
|
|
|
2010-07-10 22:24:32 +02:00
|
|
|
def addGrid(self, vbox, query, numTourneys, tourneyTypes, playerids, sitenos, seats, dates):
|
2010-07-10 23:21:36 +02:00
|
|
|
#print "start of addGrid query", query
|
2010-07-11 03:13:58 +02:00
|
|
|
#print "start of addGrid. numTourneys:",numTourneys,"tourneyTypes:", tourneyTypes, "playerids:",playerids
|
2010-07-10 05:19:50 +02:00
|
|
|
counter = 0
|
|
|
|
row = 0
|
|
|
|
sqlrow = 0
|
2010-07-11 03:13:58 +02:00
|
|
|
grid=numTourneys #TODO: should this be numTourneyTypes?
|
2010-07-10 22:24:32 +02:00
|
|
|
|
|
|
|
query = self.sql.query[query]
|
|
|
|
query = self.refineQuery(query, numTourneys, tourneyTypes, playerids, sitenos, seats, dates)
|
|
|
|
self.cursor.execute(query)
|
2010-07-10 05:19:50 +02:00
|
|
|
result = self.cursor.fetchall()
|
2010-07-10 23:21:36 +02:00
|
|
|
#print "result of the big query in addGrid:",result
|
2010-07-11 03:13:58 +02:00
|
|
|
colnames = [desc[0] for desc in self.cursor.description]
|
2010-07-10 05:19:50 +02:00
|
|
|
|
|
|
|
# pre-fetch some constant values:
|
2010-07-11 03:13:58 +02:00
|
|
|
#self.cols_to_show = [x for x in self.columns if x[colshow]]
|
|
|
|
#htourneytypeid_idx = colnames.index('tourneyTypeId')
|
|
|
|
self.cols_to_show = self.columns #TODO do i need above 2 lines?
|
|
|
|
|
2010-07-10 05:19:50 +02:00
|
|
|
assert len(self.liststore) == grid, "len(self.liststore)="+str(len(self.liststore))+" grid-1="+str(grid)
|
|
|
|
self.liststore.append( gtk.ListStore(*([str] * len(self.cols_to_show))) )
|
|
|
|
view = gtk.TreeView(model=self.liststore[grid])
|
|
|
|
view.set_grid_lines(gtk.TREE_VIEW_GRID_LINES_BOTH)
|
|
|
|
#vbox.pack_start(view, expand=False, padding=3)
|
|
|
|
vbox.add(view)
|
|
|
|
textcell = gtk.CellRendererText()
|
|
|
|
textcell50 = gtk.CellRendererText()
|
|
|
|
textcell50.set_property('xalign', 0.5)
|
|
|
|
numcell = gtk.CellRendererText()
|
|
|
|
numcell.set_property('xalign', 1.0)
|
|
|
|
assert len(self.listcols) == grid
|
|
|
|
self.listcols.append( [] )
|
|
|
|
|
|
|
|
# Create header row eg column: ("game", True, "Game", 0.0, "%s")
|
|
|
|
for col, column in enumerate(self.cols_to_show):
|
|
|
|
if column[colalias] == 'game' and holecards:
|
|
|
|
s = [x for x in self.columns if x[colalias] == 'hand'][0][colheading]
|
|
|
|
else:
|
|
|
|
s = column[colheading]
|
|
|
|
self.listcols[grid].append(gtk.TreeViewColumn(s))
|
|
|
|
view.append_column(self.listcols[grid][col])
|
|
|
|
if column[colformat] == '%s':
|
|
|
|
if column[colxalign] == 0.0:
|
|
|
|
self.listcols[grid][col].pack_start(textcell, expand=True)
|
|
|
|
self.listcols[grid][col].add_attribute(textcell, 'text', col)
|
|
|
|
cellrend = textcell
|
|
|
|
else:
|
|
|
|
self.listcols[grid][col].pack_start(textcell50, expand=True)
|
|
|
|
self.listcols[grid][col].add_attribute(textcell50, 'text', col)
|
|
|
|
cellrend = textcell50
|
|
|
|
self.listcols[grid][col].set_expand(True)
|
|
|
|
else:
|
|
|
|
self.listcols[grid][col].pack_start(numcell, expand=True)
|
|
|
|
self.listcols[grid][col].add_attribute(numcell, 'text', col)
|
|
|
|
self.listcols[grid][col].set_expand(True)
|
|
|
|
cellrend = numcell
|
|
|
|
#self.listcols[grid][col].set_alignment(column[colxalign]) # no effect?
|
|
|
|
self.listcols[grid][col].set_clickable(True)
|
2010-07-11 03:13:58 +02:00
|
|
|
self.listcols[grid][col].connect("clicked", self.sortCols, (col,grid))
|
2010-07-10 05:19:50 +02:00
|
|
|
if col == 0:
|
|
|
|
self.listcols[grid][col].set_sort_order(gtk.SORT_DESCENDING)
|
|
|
|
self.listcols[grid][col].set_sort_indicator(True)
|
|
|
|
if column[coltype] == 'cash':
|
|
|
|
self.listcols[grid][col].set_cell_data_func(numcell, self.ledger_style_render_func)
|
|
|
|
else:
|
|
|
|
self.listcols[grid][col].set_cell_data_func(cellrend, self.reset_style_render_func)
|
|
|
|
|
|
|
|
rows = len(result) # +1 for title row
|
|
|
|
|
|
|
|
while sqlrow < rows:
|
|
|
|
treerow = []
|
|
|
|
for col,column in enumerate(self.cols_to_show):
|
|
|
|
if column[colalias] in colnames:
|
|
|
|
value = result[sqlrow][colnames.index(column[colalias])]
|
|
|
|
else:
|
2010-07-11 03:13:58 +02:00
|
|
|
value = 111
|
2010-07-10 05:19:50 +02:00
|
|
|
if value and value != -999:
|
|
|
|
treerow.append(column[colformat] % value)
|
|
|
|
else:
|
|
|
|
treerow.append(' ')
|
2010-07-11 03:13:58 +02:00
|
|
|
#print "addGrid, just before end of big for. grid:",grid,"treerow:",treerow
|
2010-07-10 05:19:50 +02:00
|
|
|
iter = self.liststore[grid].append(treerow)
|
|
|
|
sqlrow += 1
|
|
|
|
row += 1
|
|
|
|
vbox.show_all()
|
|
|
|
#end def addGrid
|
|
|
|
|
|
|
|
def createStatsTable(self, vbox, tourneyTypes, playerids, sitenos, seats, dates):
|
|
|
|
startTime = time()
|
2010-07-10 02:09:58 +02:00
|
|
|
show_detail = True
|
|
|
|
|
|
|
|
# Scrolled window for summary table
|
|
|
|
swin = gtk.ScrolledWindow(hadjustment=None, vadjustment=None)
|
|
|
|
swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
|
|
|
swin.show()
|
|
|
|
vbox.pack1(swin)
|
|
|
|
|
2010-07-10 22:24:32 +02:00
|
|
|
numTourneys = self.filters.getNumTourneys()
|
|
|
|
self.addGrid(swin, 'tourneyPlayerDetailedStats', numTourneys, tourneyTypes, playerids
|
2010-07-10 05:19:50 +02:00
|
|
|
,sitenos, seats, dates)
|
2010-07-10 02:09:58 +02:00
|
|
|
|
2010-07-11 03:13:58 +02:00
|
|
|
#if 'allplayers' in groups and groups['allplayers']:
|
2010-07-10 02:09:58 +02:00
|
|
|
# can't currently do this combination so skip detailed table
|
2010-07-11 03:13:58 +02:00
|
|
|
show_detail = False
|
2010-07-10 02:09:58 +02:00
|
|
|
|
|
|
|
if show_detail:
|
|
|
|
# Separator
|
|
|
|
vbox2 = gtk.VBox(False, 0)
|
|
|
|
heading = gtk.Label(self.filterText['handhead'])
|
|
|
|
heading.show()
|
|
|
|
vbox2.pack_start(heading, expand=False, padding=3)
|
|
|
|
|
|
|
|
# Scrolled window for detailed table (display by hand)
|
|
|
|
swin = gtk.ScrolledWindow(hadjustment=None, vadjustment=None)
|
|
|
|
swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
|
|
|
swin.show()
|
|
|
|
vbox2.pack_start(swin, expand=True, padding=3)
|
|
|
|
vbox.pack2(vbox2)
|
|
|
|
vbox2.show()
|
|
|
|
|
|
|
|
# Detailed table
|
|
|
|
flags[0] = True
|
|
|
|
flags[2] = 1
|
2010-07-10 05:19:50 +02:00
|
|
|
self.addGrid(swin, 'playerDetailedStats', flags, playerids, sitenos, seats, dates)
|
2010-07-10 02:09:58 +02:00
|
|
|
|
|
|
|
self.db.rollback()
|
2010-07-10 05:19:50 +02:00
|
|
|
print "Stats page displayed in %4.2f seconds" % (time() - startTime)
|
2010-07-10 02:09:58 +02:00
|
|
|
#end def createStatsTable
|
|
|
|
|
|
|
|
def fillStatsFrame(self, vbox):
|
2010-07-10 05:19:50 +02:00
|
|
|
tourneyTypes = self.filters.getTourneyTypes()
|
|
|
|
#tourneys = self.tourneys.getTourneys()
|
2010-07-10 02:09:58 +02:00
|
|
|
sites = self.filters.getSites()
|
|
|
|
heroes = self.filters.getHeroes()
|
|
|
|
siteids = self.filters.getSiteIds()
|
|
|
|
seats = self.filters.getSeats()
|
|
|
|
dates = self.filters.getDates()
|
|
|
|
sitenos = []
|
|
|
|
playerids = []
|
|
|
|
|
|
|
|
# Which sites are selected?
|
|
|
|
for site in sites:
|
|
|
|
if sites[site] == True:
|
|
|
|
sitenos.append(siteids[site])
|
|
|
|
_hname = Charset.to_utf8(heroes[site])
|
|
|
|
result = self.db.get_player_id(self.conf, site, _hname)
|
|
|
|
if result is not None:
|
|
|
|
playerids.append(int(result))
|
|
|
|
|
|
|
|
if not sitenos:
|
|
|
|
#Should probably pop up here.
|
|
|
|
print "No sites selected - defaulting to PokerStars"
|
|
|
|
sitenos = [2]
|
|
|
|
if not playerids:
|
|
|
|
print "No player ids found"
|
|
|
|
return
|
2010-07-10 05:19:50 +02:00
|
|
|
|
|
|
|
self.createStatsTable(vbox, tourneyTypes, playerids, sitenos, seats, dates)
|
2010-07-10 02:09:58 +02:00
|
|
|
#end def fillStatsFrame
|
2010-07-09 04:47:33 +02:00
|
|
|
|
2010-07-10 02:09:58 +02:00
|
|
|
def get_vbox(self):
|
|
|
|
"""returns the vbox of this thread"""
|
|
|
|
return self.main_hbox
|
|
|
|
#end def get_vbox
|
|
|
|
|
2010-07-10 22:24:32 +02:00
|
|
|
def refineQuery(self, query, numTourneys, tourneyTypes, playerids, sitenos, seats, dates):
|
2010-07-10 05:19:50 +02:00
|
|
|
having = ''
|
2010-07-10 22:24:32 +02:00
|
|
|
|
2010-07-10 23:21:36 +02:00
|
|
|
#print "start of refinequery, playerids:",playerids
|
2010-07-10 06:23:47 +02:00
|
|
|
if playerids:
|
|
|
|
nametest = str(tuple(playerids))
|
|
|
|
nametest = nametest.replace("L", "")
|
|
|
|
nametest = nametest.replace(",)",")")
|
|
|
|
else:
|
|
|
|
nametest = "1 = 2"
|
2010-07-10 23:21:36 +02:00
|
|
|
#print "refinequery, nametest after initial creation:",nametest
|
2010-07-10 05:19:50 +02:00
|
|
|
pname = "p.name"
|
2010-07-10 06:23:47 +02:00
|
|
|
# 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
|
|
|
|
|
2010-07-10 22:24:32 +02:00
|
|
|
query = query.replace("<nametest>", nametest)
|
2010-07-10 05:19:50 +02:00
|
|
|
query = query.replace("<playerName>", pname)
|
|
|
|
query = query.replace("<havingclause>", having)
|
|
|
|
|
2010-07-10 22:24:32 +02:00
|
|
|
#TODO: remove, or replace with tourneytest
|
|
|
|
#gametest = ""
|
|
|
|
#q = []
|
|
|
|
#for m in self.filters.display.items():
|
|
|
|
# if m[0] == 'Games' and m[1]:
|
|
|
|
# for n in games:
|
|
|
|
# if games[n]:
|
|
|
|
# q.append(n)
|
|
|
|
# if len(q) > 0:
|
|
|
|
# gametest = str(tuple(q))
|
|
|
|
# gametest = gametest.replace("L", "")
|
|
|
|
# gametest = gametest.replace(",)",")")
|
|
|
|
# gametest = gametest.replace("u'","'")
|
|
|
|
# gametest = "and gt.category in %s" % gametest
|
|
|
|
# else:
|
|
|
|
# gametest = "and gt.category IS NULL"
|
|
|
|
#query = query.replace("<game_test>", gametest)
|
2010-07-10 05:19:50 +02:00
|
|
|
|
|
|
|
sitetest = ""
|
|
|
|
q = []
|
|
|
|
for m in self.filters.display.items():
|
|
|
|
if m[0] == 'Sites' and m[1]:
|
|
|
|
for n in sitenos:
|
|
|
|
q.append(n)
|
|
|
|
if len(q) > 0:
|
|
|
|
sitetest = str(tuple(q))
|
|
|
|
sitetest = sitetest.replace("L", "")
|
|
|
|
sitetest = sitetest.replace(",)",")")
|
|
|
|
sitetest = sitetest.replace("u'","'")
|
2010-07-10 22:24:32 +02:00
|
|
|
sitetest = "and tt.siteId in %s" % sitetest#[1:-1]
|
2010-07-10 05:19:50 +02:00
|
|
|
else:
|
2010-07-10 22:24:32 +02:00
|
|
|
sitetest = "and tt.siteId IS NULL"
|
2010-07-10 23:21:36 +02:00
|
|
|
#print "refinequery, sitetest before its use for replacement:",sitetest
|
2010-07-10 22:24:32 +02:00
|
|
|
query = query.replace("<sitetest>", sitetest)
|
2010-07-10 05:19:50 +02:00
|
|
|
|
|
|
|
if seats:
|
|
|
|
query = query.replace('<seats_test>', 'between ' + str(seats['from']) + ' and ' + str(seats['to']))
|
|
|
|
if 'show' in seats and seats['show']:
|
|
|
|
query = query.replace('<groupbyseats>', ',h.seats')
|
|
|
|
query = query.replace('<orderbyseats>', ',h.seats')
|
|
|
|
else:
|
|
|
|
query = query.replace('<groupbyseats>', '')
|
|
|
|
query = query.replace('<orderbyseats>', '')
|
|
|
|
else:
|
|
|
|
query = query.replace('<seats_test>', 'between 0 and 100')
|
|
|
|
query = query.replace('<groupbyseats>', '')
|
|
|
|
query = query.replace('<orderbyseats>', '')
|
|
|
|
|
2010-07-10 06:23:47 +02:00
|
|
|
#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']
|
|
|
|
#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 "
|
2010-07-10 05:19:50 +02:00
|
|
|
# and ( (limit and bb in()) or (nolimit and bb in ()) )
|
2010-07-10 06:23:47 +02:00
|
|
|
#if lims:
|
|
|
|
# blindtest = str(tuple(lims))
|
|
|
|
# blindtest = blindtest.replace("L", "")
|
|
|
|
# blindtest = blindtest.replace(",)",")")
|
|
|
|
# bbtest = bbtest + blindtest + ' ) '
|
|
|
|
#else:
|
|
|
|
# bbtest = bbtest + '(-1) ) '
|
|
|
|
#bbtest = bbtest + " or (gt.limitType = 'pl' and gt.bigBlind in "
|
|
|
|
#if potlims:
|
|
|
|
# blindtest = str(tuple(potlims))
|
|
|
|
# blindtest = blindtest.replace("L", "")
|
|
|
|
# blindtest = blindtest.replace(",)",")")
|
|
|
|
# bbtest = bbtest + blindtest + ' ) '
|
|
|
|
#else:
|
|
|
|
# bbtest = bbtest + '(-1) ) '
|
|
|
|
#bbtest = bbtest + " or (gt.limitType = 'nl' and gt.bigBlind in "
|
|
|
|
#if nolims:
|
|
|
|
# blindtest = str(tuple(nolims))
|
|
|
|
# blindtest = blindtest.replace("L", "")
|
|
|
|
# blindtest = blindtest.replace(",)",")")
|
|
|
|
# bbtest = bbtest + blindtest + ' ) )'
|
|
|
|
#else:
|
|
|
|
# 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)
|
2010-07-10 05:19:50 +02:00
|
|
|
|
2010-07-10 06:23:47 +02:00
|
|
|
#query = query.replace("<orderbyhgameTypeId>", "")
|
|
|
|
|
2010-07-10 05:19:50 +02:00
|
|
|
# process self.detailFilters (a list of tuples)
|
|
|
|
flagtest = ''
|
|
|
|
#self.detailFilters = [('h.seats', 5, 6)] # for debug
|
|
|
|
if self.detailFilters:
|
|
|
|
for f in self.detailFilters:
|
|
|
|
if len(f) == 3:
|
|
|
|
# X between Y and Z
|
|
|
|
flagtest += ' and %s between %s and %s ' % (f[0], str(f[1]), str(f[2]))
|
|
|
|
query = query.replace("<flagtest>", flagtest)
|
|
|
|
|
|
|
|
# allow for differences in sql cast() function:
|
2010-07-10 06:23:47 +02:00
|
|
|
if self.db.backend == self.db.MYSQL_INNODB:
|
2010-07-10 05:19:50 +02:00
|
|
|
query = query.replace("<signed>", 'signed ')
|
|
|
|
else:
|
|
|
|
query = query.replace("<signed>", '')
|
|
|
|
|
|
|
|
# Filter on dates
|
|
|
|
query = query.replace("<datestest>", " between '" + dates[0] + "' and '" + dates[1] + "'")
|
|
|
|
|
|
|
|
# Group by position?
|
2010-07-10 06:23:47 +02:00
|
|
|
#if groups['posn']:
|
|
|
|
# #query = query.replace("<position>", "case hp.position when '0' then 'Btn' else hp.position end")
|
|
|
|
# query = query.replace("<position>", "hp.position")
|
|
|
|
# # set flag in self.columns to show posn column
|
|
|
|
# [x for x in self.columns if x[0] == 'plposition'][0][1] = True
|
|
|
|
#else:
|
|
|
|
# query = query.replace("<position>", "gt.base")
|
|
|
|
# # unset flag in self.columns to hide posn column
|
|
|
|
# [x for x in self.columns if x[0] == 'plposition'][0][1] = False
|
|
|
|
|
2010-07-10 23:21:36 +02:00
|
|
|
#print "query at end of refine query:", query
|
2010-07-10 05:19:50 +02:00
|
|
|
return(query)
|
|
|
|
#end def refineQuery
|
|
|
|
|
2010-07-10 02:09:58 +02:00
|
|
|
def refreshStats(self, widget, data):
|
|
|
|
self.last_pos = self.stats_vbox.get_position()
|
|
|
|
try: self.stats_vbox.destroy()
|
|
|
|
except AttributeError: pass
|
|
|
|
self.liststore = []
|
|
|
|
self.listcols = []
|
|
|
|
#self.stats_vbox = gtk.VBox(False, 0)
|
|
|
|
self.stats_vbox = gtk.VPaned()
|
|
|
|
self.stats_vbox.show()
|
|
|
|
self.stats_frame.add(self.stats_vbox)
|
|
|
|
self.fillStatsFrame(self.stats_vbox)
|
|
|
|
if self.last_pos > 0:
|
|
|
|
self.stats_vbox.set_position(self.last_pos)
|
|
|
|
#end def refreshStats
|
2010-07-11 03:13:58 +02:00
|
|
|
|
|
|
|
def reset_style_render_func(self, treeviewcolumn, cell, model, iter):
|
|
|
|
cell.set_property('foreground', 'black')
|
|
|
|
#end def reset_style_render_func
|
|
|
|
|
|
|
|
def sortCols(self, col, nums):
|
|
|
|
try:
|
|
|
|
#This doesn't actually work yet - clicking heading in top section sorts bottom section :-(
|
|
|
|
(n, grid) = nums
|
|
|
|
if not col.get_sort_indicator() or col.get_sort_order() == gtk.SORT_ASCENDING:
|
|
|
|
col.set_sort_order(gtk.SORT_DESCENDING)
|
|
|
|
else:
|
|
|
|
col.set_sort_order(gtk.SORT_ASCENDING)
|
|
|
|
self.liststore[grid].set_sort_column_id(n, col.get_sort_order())
|
|
|
|
self.liststore[grid].set_sort_func(n, self.sortnums, (n,grid))
|
|
|
|
for i in xrange(len(self.listcols[grid])):
|
|
|
|
self.listcols[grid][i].set_sort_indicator(False)
|
|
|
|
self.listcols[grid][n].set_sort_indicator(True)
|
|
|
|
# use this listcols[col].set_sort_indicator(True)
|
|
|
|
# to turn indicator off for other cols
|
|
|
|
except:
|
|
|
|
err = traceback.extract_tb(sys.exc_info()[2])
|
|
|
|
print "***sortCols error: " + str(sys.exc_info()[1])
|
|
|
|
print "\n".join( [e[0]+':'+str(e[1])+" "+e[2] for e in err] )
|
|
|
|
#end def sortCols
|
2010-07-10 02:09:58 +02:00
|
|
|
#end class GuiTourneyPlayerStats
|