2010-07-08 20:01:03 +02:00
|
|
|
#!/usr/bin/python
|
2010-07-04 03:05:16 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
2009-03-03 12:32:01 +01:00
|
|
|
|
2010-07-04 03:05:16 +02:00
|
|
|
#Copyright 2008-2010 Steffen Schaumburg
|
2009-03-03 12:32:01 +01:00
|
|
|
#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/>.
|
2010-07-04 03:05:16 +02:00
|
|
|
#In the "official" distribution you can find the license in agpl-3.0.txt.
|
2009-03-03 12:32:01 +01:00
|
|
|
|
2011-02-06 07:03:11 +01:00
|
|
|
import L10n
|
|
|
|
_ = L10n.get_translation()
|
|
|
|
|
2009-03-03 12:32:01 +01:00
|
|
|
import threading
|
|
|
|
import pygtk
|
|
|
|
pygtk.require('2.0')
|
|
|
|
import gtk
|
|
|
|
import os
|
2009-06-22 23:05:28 +02:00
|
|
|
from time import time, strftime
|
2009-03-03 12:32:01 +01:00
|
|
|
|
|
|
|
import fpdb_import
|
2009-07-19 19:28:13 +02:00
|
|
|
import Database
|
2010-07-17 03:39:31 +02:00
|
|
|
import Filters
|
2009-03-03 12:32:01 +01:00
|
|
|
|
|
|
|
class GuiPositionalStats (threading.Thread):
|
2009-05-04 21:36:11 +02:00
|
|
|
def __init__(self, config, querylist, debug=True):
|
2009-07-19 19:28:13 +02:00
|
|
|
self.debug = debug
|
|
|
|
self.conf = config
|
|
|
|
self.sql = querylist
|
2009-05-05 00:14:33 +02:00
|
|
|
self.MYSQL_INNODB = 2
|
|
|
|
self.PGSQL = 3
|
|
|
|
self.SQLITE = 4
|
2009-03-03 12:32:01 +01:00
|
|
|
|
|
|
|
# create new db connection to avoid conflicts with other threads
|
2009-07-19 19:28:13 +02:00
|
|
|
self.db = Database.Database(self.conf, sql=self.sql)
|
|
|
|
self.cursor = self.db.cursor
|
2009-03-03 12:32:01 +01:00
|
|
|
|
2009-04-11 14:07:50 +02:00
|
|
|
settings = {}
|
2009-07-19 19:28:13 +02:00
|
|
|
settings.update(self.conf.get_db_parameters())
|
|
|
|
settings.update(self.conf.get_import_parameters())
|
|
|
|
settings.update(self.conf.get_default_paths())
|
2009-04-11 14:07:50 +02:00
|
|
|
|
2009-05-04 21:12:41 +02:00
|
|
|
filters_display = { "Heroes" : True,
|
|
|
|
"Sites" : True,
|
|
|
|
"Games" : False,
|
|
|
|
"Limits" : True,
|
|
|
|
"LimitSep" : True,
|
2009-05-08 23:41:09 +02:00
|
|
|
"Seats" : True,
|
2009-05-11 00:06:35 +02:00
|
|
|
"SeatSep" : True,
|
2009-05-28 20:54:32 +02:00
|
|
|
"Dates" : True,
|
2009-05-04 21:12:41 +02:00
|
|
|
"Button1" : True,
|
|
|
|
"Button2" : False
|
2009-04-17 06:44:43 +02:00
|
|
|
}
|
|
|
|
|
2010-07-17 03:39:31 +02:00
|
|
|
self.filters = Filters.Filters(self.db, self.conf, self.sql, display = filters_display)
|
2009-05-03 11:49:00 +02:00
|
|
|
self.filters.registerButton1Name("Refresh")
|
|
|
|
self.filters.registerButton1Callback(self.refreshStats)
|
2009-03-03 12:32:01 +01:00
|
|
|
|
2009-06-22 22:39:14 +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
|
|
|
|
self.columns = [ ["game", True, "Game", 0.0, "%s"]
|
|
|
|
, ["hand", False, "Hand", 0.0, "%s"] # true not allowed for this line
|
|
|
|
, ["plposition", False, "Posn", 1.0, "%s"] # true not allowed for this line (set in code)
|
|
|
|
, ["n", True, "Hds", 1.0, "%d"]
|
|
|
|
, ["avgseats", True, "Seats", 1.0, "%3.1f"]
|
|
|
|
, ["vpip", True, "VPIP", 1.0, "%3.1f"]
|
|
|
|
, ["pfr", True, "PFR", 1.0, "%3.1f"]
|
|
|
|
, ["pf3", True, "PF3", 1.0, "%3.1f"]
|
|
|
|
, ["steals", True, "Steals", 1.0, "%3.1f"]
|
|
|
|
, ["saw_f", True, "Saw_F", 1.0, "%3.1f"]
|
|
|
|
, ["sawsd", True, "SawSD", 1.0, "%3.1f"]
|
|
|
|
, ["wtsdwsf", True, "WtSDwsF", 1.0, "%3.1f"]
|
|
|
|
, ["wmsd", True, "W$SD", 1.0, "%3.1f"]
|
|
|
|
, ["flafq", True, "FlAFq", 1.0, "%3.1f"]
|
|
|
|
, ["tuafq", True, "TuAFq", 1.0, "%3.1f"]
|
|
|
|
, ["rvafq", True, "RvAFq", 1.0, "%3.1f"]
|
|
|
|
, ["pofafq", False, "PoFAFq", 1.0, "%3.1f"]
|
|
|
|
, ["net", True, "Net($)", 1.0, "%6.2f"]
|
|
|
|
, ["bbper100", True, "bb/100", 1.0, "%4.2f"]
|
|
|
|
, ["rake", True, "Rake($)", 1.0, "%6.2f"]
|
|
|
|
, ["bb100xr", True, "bbxr/100", 1.0, "%4.2f"]
|
|
|
|
, ["variance", True, "Variance", 1.0, "%5.2f"]
|
|
|
|
]
|
|
|
|
|
2009-03-03 12:32:01 +01:00
|
|
|
self.stat_table = None
|
|
|
|
self.stats_frame = None
|
2009-06-22 22:39:14 +02:00
|
|
|
self.stats_vbox = None
|
2009-03-03 12:32:01 +01:00
|
|
|
|
|
|
|
self.main_hbox = gtk.HBox(False, 0)
|
|
|
|
self.main_hbox.show()
|
|
|
|
|
2009-06-22 22:39:14 +02:00
|
|
|
self.stats_frame = gtk.Frame()
|
|
|
|
self.stats_frame.set_label_align(0.0, 0.0)
|
2009-03-03 12:32:01 +01:00
|
|
|
self.stats_frame.show()
|
2009-06-22 22:39:14 +02:00
|
|
|
self.stats_vbox = gtk.VBox(False, 0)
|
|
|
|
self.stats_vbox.show()
|
2009-03-03 12:32:01 +01:00
|
|
|
|
2009-05-04 03:10:05 +02:00
|
|
|
# This could be stored in config eventually, or maybe configured in this window somehow.
|
|
|
|
# Each posncols element is the name of a column returned by the sql
|
|
|
|
# query (in lower case) and each posnheads element is the text to use as
|
|
|
|
# the heading in the GUI. Both sequences should be the same length.
|
|
|
|
# To miss columns out remove them from both tuples (the 1st 2 elements should always be included).
|
|
|
|
# To change the heading just edit the second list element as required
|
|
|
|
# If the first list element does not match a query column that pair is ignored
|
2009-05-08 23:41:09 +02:00
|
|
|
self.posncols = ( "game", "avgseats", "plposition", "vpip", "pfr", "pf3", "steals"
|
2009-05-04 03:10:05 +02:00
|
|
|
, "saw_f", "sawsd", "wtsdwsf", "wmsd", "flafq", "tuafq", "rvafq"
|
2009-05-08 23:41:09 +02:00
|
|
|
, "pofafq", "net", "bbper100", "profitperhand", "variance", "n"
|
|
|
|
)
|
|
|
|
self.posnheads = ( "Game", "Seats", "Posn", "VPIP", "PFR", "PF3", "Steals"
|
2009-05-04 03:10:05 +02:00
|
|
|
, "Saw_F", "SawSD", "WtSDwsF", "W$SD", "FlAFq", "TuAFq", "RvAFq"
|
2009-05-30 23:33:08 +02:00
|
|
|
, "PoFAFq", "Net($)", "bb/100", "$/hand", "Variance", "Hds"
|
2009-05-08 23:41:09 +02:00
|
|
|
)
|
2009-05-04 03:10:05 +02:00
|
|
|
|
2009-06-22 22:39:14 +02:00
|
|
|
self.fillStatsFrame(self.stats_vbox)
|
|
|
|
self.stats_frame.add(self.stats_vbox)
|
2009-03-03 12:32:01 +01:00
|
|
|
|
2009-04-11 14:07:50 +02:00
|
|
|
self.main_hbox.pack_start(self.filters.get_vbox())
|
2009-06-22 22:39:14 +02:00
|
|
|
self.main_hbox.pack_start(self.stats_frame)
|
2009-03-03 12:32:01 +01:00
|
|
|
|
2009-05-04 03:10:05 +02:00
|
|
|
|
2009-04-11 14:07:50 +02:00
|
|
|
def get_vbox(self):
|
|
|
|
"""returns the vbox of this thread"""
|
|
|
|
return self.main_hbox
|
|
|
|
|
|
|
|
def toggleCallback(self, widget, data=None):
|
|
|
|
# print "%s was toggled %s" % (data, ("OFF", "ON")[widget.get_active()])
|
|
|
|
self.activesite = data
|
2010-08-14 18:56:28 +02:00
|
|
|
print _("DEBUG: activesite set to %s") %(self.activesite)
|
2009-04-11 14:07:50 +02:00
|
|
|
|
|
|
|
def refreshStats(self, widget, data):
|
2009-06-22 22:39:14 +02:00
|
|
|
try: self.stats_vbox.destroy()
|
2009-04-11 14:07:50 +02:00
|
|
|
except AttributeError: pass
|
2009-06-22 22:39:14 +02:00
|
|
|
self.stats_vbox = gtk.VBox(False, 0)
|
|
|
|
self.stats_vbox.show()
|
|
|
|
self.stats_frame.add(self.stats_vbox)
|
|
|
|
self.fillStatsFrame(self.stats_vbox)
|
2009-04-11 14:07:50 +02:00
|
|
|
|
|
|
|
def fillStatsFrame(self, vbox):
|
|
|
|
sites = self.filters.getSites()
|
|
|
|
heroes = self.filters.getHeroes()
|
|
|
|
siteids = self.filters.getSiteIds()
|
2009-05-04 21:12:41 +02:00
|
|
|
limits = self.filters.getLimits()
|
2009-05-08 23:41:09 +02:00
|
|
|
seats = self.filters.getSeats()
|
2009-05-28 20:54:32 +02:00
|
|
|
dates = self.filters.getDates()
|
2009-04-11 14:07:50 +02:00
|
|
|
sitenos = []
|
|
|
|
playerids = []
|
|
|
|
|
|
|
|
# Which sites are selected?
|
|
|
|
for site in sites:
|
|
|
|
if sites[site] == True:
|
|
|
|
sitenos.append(siteids[site])
|
|
|
|
self.cursor.execute(self.sql.query['getPlayerId'], (heroes[site],))
|
|
|
|
result = self.db.cursor.fetchall()
|
|
|
|
if len(result) == 1:
|
|
|
|
playerids.append(result[0][0])
|
|
|
|
|
|
|
|
if not sitenos:
|
|
|
|
#Should probably pop up here.
|
2010-08-14 18:56:28 +02:00
|
|
|
print _("No sites selected - defaulting to PokerStars")
|
2009-04-11 14:07:50 +02:00
|
|
|
sitenos = [2]
|
|
|
|
if not playerids:
|
2010-08-14 18:56:28 +02:00
|
|
|
print _("No player ids found")
|
2009-04-11 14:07:50 +02:00
|
|
|
return
|
2009-05-04 21:12:41 +02:00
|
|
|
if not limits:
|
2010-08-14 18:56:28 +02:00
|
|
|
print _("No limits found")
|
2009-05-04 21:12:41 +02:00
|
|
|
return
|
2009-04-11 14:07:50 +02:00
|
|
|
|
2009-05-28 20:54:32 +02:00
|
|
|
self.createStatsTable(vbox, playerids, sitenos, limits, seats, dates)
|
2009-05-11 00:06:35 +02:00
|
|
|
|
2009-05-28 20:54:32 +02:00
|
|
|
def createStatsTable(self, vbox, playerids, sitenos, limits, seats, dates):
|
2009-04-11 14:07:50 +02:00
|
|
|
|
2009-06-22 23:05:28 +02:00
|
|
|
starttime = time()
|
2009-06-22 22:39:14 +02:00
|
|
|
colalias,colshow,colheading,colxalign,colformat = 0,1,2,3,4
|
2009-05-11 00:06:35 +02:00
|
|
|
row = 0
|
2009-04-11 14:07:50 +02:00
|
|
|
col = 0
|
|
|
|
|
2009-05-11 00:06:35 +02:00
|
|
|
tmp = self.sql.query['playerStatsByPosition']
|
2009-05-28 20:54:32 +02:00
|
|
|
tmp = self.refineQuery(tmp, playerids, sitenos, limits, seats, dates)
|
2009-05-11 00:06:35 +02:00
|
|
|
self.cursor.execute(tmp)
|
|
|
|
result = self.cursor.fetchall()
|
2009-06-22 22:39:14 +02:00
|
|
|
colnames = [desc[0].lower() for desc in self.cursor.description]
|
|
|
|
|
|
|
|
liststore = gtk.ListStore(*([str] * len(colnames)))
|
|
|
|
view = gtk.TreeView(model=liststore)
|
|
|
|
view.set_grid_lines(gtk.TREE_VIEW_GRID_LINES_BOTH)
|
|
|
|
vbox.pack_start(view, expand=False, padding=3)
|
|
|
|
# left-aligned cells:
|
|
|
|
textcell = gtk.CellRendererText()
|
|
|
|
# centred cells:
|
|
|
|
textcell50 = gtk.CellRendererText()
|
|
|
|
textcell50.set_property('xalign', 0.5)
|
|
|
|
# right-aligned cells:
|
|
|
|
numcell = gtk.CellRendererText()
|
|
|
|
numcell.set_property('xalign', 1.0)
|
|
|
|
listcols = []
|
|
|
|
|
|
|
|
for t in self.posnheads:
|
|
|
|
listcols.append(gtk.TreeViewColumn(self.posnheads[col]))
|
|
|
|
view.append_column(listcols[col])
|
|
|
|
if col == 0:
|
|
|
|
listcols[col].pack_start(textcell, expand=True)
|
|
|
|
listcols[col].add_attribute(textcell, 'text', col)
|
|
|
|
listcols[col].set_expand(True)
|
|
|
|
elif col in (1, 2):
|
|
|
|
listcols[col].pack_start(textcell50, expand=True)
|
|
|
|
listcols[col].add_attribute(textcell50, 'text', col)
|
|
|
|
listcols[col].set_expand(True)
|
|
|
|
else:
|
|
|
|
listcols[col].pack_start(numcell, expand=True)
|
|
|
|
listcols[col].add_attribute(numcell, 'text', col)
|
|
|
|
listcols[col].set_expand(True)
|
|
|
|
col +=1
|
|
|
|
|
|
|
|
# Code below to be used when full column data structures implemented like in player stats:
|
|
|
|
|
|
|
|
# Create header row eg column: ("game", True, "Game", 0.0, "%s")
|
|
|
|
#for col, column in enumerate(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]
|
|
|
|
# listcols.append(gtk.TreeViewColumn(s))
|
|
|
|
# view.append_column(listcols[col])
|
|
|
|
# if column[colformat] == '%s':
|
|
|
|
# if column[colxalign] == 0.0:
|
|
|
|
# listcols[col].pack_start(textcell, expand=True)
|
|
|
|
# listcols[col].add_attribute(textcell, 'text', col)
|
|
|
|
# else:
|
|
|
|
# listcols[col].pack_start(textcell50, expand=True)
|
|
|
|
# listcols[col].add_attribute(textcell50, 'text', col)
|
|
|
|
# listcols[col].set_expand(True)
|
|
|
|
# else:
|
|
|
|
# listcols[col].pack_start(numcell, expand=True)
|
|
|
|
# listcols[col].add_attribute(numcell, 'text', col)
|
|
|
|
# listcols[col].set_expand(True)
|
|
|
|
# #listcols[col].set_alignment(column[colxalign]) # no effect?
|
2009-05-11 00:06:35 +02:00
|
|
|
|
|
|
|
rows = len(result)
|
|
|
|
|
2009-05-08 23:41:09 +02:00
|
|
|
last_game,last_seats,sqlrow = "","",0
|
2009-05-03 11:49:00 +02:00
|
|
|
while sqlrow < rows:
|
|
|
|
rowprinted=0
|
2009-06-22 22:39:14 +02:00
|
|
|
treerow = []
|
2009-05-08 23:41:09 +02:00
|
|
|
avgcol = colnames.index('avgseats')
|
2009-05-04 03:10:05 +02:00
|
|
|
for col,colname in enumerate(self.posncols):
|
|
|
|
if colname in colnames:
|
|
|
|
sqlcol = colnames.index(colname)
|
|
|
|
else:
|
|
|
|
continue
|
2009-05-08 23:41:09 +02:00
|
|
|
if result[sqlrow][sqlcol]:
|
|
|
|
if sqlrow == 0:
|
2009-06-22 22:39:14 +02:00
|
|
|
value = result[sqlrow][sqlcol]
|
2009-05-08 23:41:09 +02:00
|
|
|
rowprinted=1
|
|
|
|
elif result[sqlrow][0] != last_game:
|
2009-06-22 22:39:14 +02:00
|
|
|
value = ' '
|
2009-05-08 23:41:09 +02:00
|
|
|
elif 'show' in seats and seats['show'] and result[sqlrow][avgcol] != last_seats:
|
2009-06-22 22:39:14 +02:00
|
|
|
value = ' '
|
2009-05-08 23:41:09 +02:00
|
|
|
else:
|
2009-06-22 22:39:14 +02:00
|
|
|
value = result[sqlrow][sqlcol]
|
2009-05-08 23:41:09 +02:00
|
|
|
rowprinted=1
|
2009-04-11 14:07:50 +02:00
|
|
|
else:
|
|
|
|
l = gtk.Label(' ')
|
2009-06-22 22:39:14 +02:00
|
|
|
value = ' '
|
|
|
|
if value and value != -999:
|
|
|
|
treerow.append(value)
|
2009-04-11 14:07:50 +02:00
|
|
|
else:
|
2009-06-22 22:39:14 +02:00
|
|
|
treerow.append(' ')
|
|
|
|
iter = liststore.append(treerow)
|
2009-05-03 11:49:00 +02:00
|
|
|
last_game = result[sqlrow][0]
|
2009-05-08 23:41:09 +02:00
|
|
|
last_seats = result[sqlrow][avgcol]
|
2009-05-03 11:49:00 +02:00
|
|
|
if rowprinted:
|
|
|
|
sqlrow = sqlrow+1
|
|
|
|
row = row + 1
|
|
|
|
|
|
|
|
# show totals at bottom
|
|
|
|
tmp = self.sql.query['playerStats']
|
2009-05-28 20:54:32 +02:00
|
|
|
tmp = self.refineQuery(tmp, playerids, sitenos, limits, seats, dates)
|
2009-05-03 11:49:00 +02:00
|
|
|
self.cursor.execute(tmp)
|
|
|
|
result = self.cursor.fetchall()
|
|
|
|
rows = len(result)
|
2009-05-04 03:10:05 +02:00
|
|
|
colnames = [desc[0].lower() for desc in self.cursor.description]
|
2009-05-03 11:49:00 +02:00
|
|
|
|
2009-05-04 21:12:41 +02:00
|
|
|
# blank row between main stats and totals:
|
2009-05-03 11:49:00 +02:00
|
|
|
col = 0
|
2009-06-22 22:39:14 +02:00
|
|
|
treerow = [' ' for x in self.posncols]
|
|
|
|
iter = liststore.append(treerow)
|
2009-05-03 11:49:00 +02:00
|
|
|
row = row + 1
|
|
|
|
|
|
|
|
for sqlrow in range(rows):
|
2009-06-22 22:39:14 +02:00
|
|
|
treerow = []
|
2009-05-04 03:10:05 +02:00
|
|
|
for col,colname in enumerate(self.posncols):
|
|
|
|
if colname in colnames:
|
|
|
|
sqlcol = colnames.index(colname)
|
|
|
|
elif colname != "plposition":
|
|
|
|
continue
|
|
|
|
if colname == 'plposition':
|
2009-05-03 11:49:00 +02:00
|
|
|
l = gtk.Label('Totals')
|
2009-06-22 22:39:14 +02:00
|
|
|
value = 'Totals'
|
2009-05-04 03:10:05 +02:00
|
|
|
elif result[sqlrow][sqlcol]:
|
|
|
|
l = gtk.Label(result[sqlrow][sqlcol])
|
2009-06-22 22:39:14 +02:00
|
|
|
value = result[sqlrow][sqlcol]
|
2009-05-03 11:49:00 +02:00
|
|
|
else:
|
|
|
|
l = gtk.Label(' ')
|
2009-06-22 22:39:14 +02:00
|
|
|
value = ' '
|
|
|
|
if value and value != -999:
|
|
|
|
treerow.append(value)
|
2009-05-03 11:49:00 +02:00
|
|
|
else:
|
2009-06-22 22:39:14 +02:00
|
|
|
treerow.append(' ')
|
|
|
|
iter = liststore.append(treerow)
|
2009-05-03 11:49:00 +02:00
|
|
|
row = row + 1
|
2009-06-22 22:39:14 +02:00
|
|
|
vbox.show_all()
|
2009-05-03 11:49:00 +02:00
|
|
|
|
2009-07-19 19:28:13 +02:00
|
|
|
self.db.rollback()
|
2010-08-14 18:56:28 +02:00
|
|
|
print _("Positional Stats page displayed in %4.2f seconds") % (time() - starttime)
|
2009-04-11 14:07:50 +02:00
|
|
|
#end def fillStatsFrame(self, vbox):
|
2009-05-03 11:49:00 +02:00
|
|
|
|
2009-05-28 20:54:32 +02:00
|
|
|
def refineQuery(self, query, playerids, sitenos, limits, seats, dates):
|
2009-05-04 21:36:11 +02:00
|
|
|
if playerids:
|
|
|
|
nametest = str(tuple(playerids))
|
|
|
|
nametest = nametest.replace("L", "")
|
|
|
|
nametest = nametest.replace(",)",")")
|
|
|
|
query = query.replace("<player_test>", nametest)
|
|
|
|
else:
|
|
|
|
query = query.replace("<player_test>", "1 = 2")
|
2009-05-04 21:12:41 +02:00
|
|
|
|
2009-05-08 23:41:09 +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>', ',hc.activeSeats')
|
|
|
|
query = query.replace('<orderbyseats>', ',stats.AvgSeats')
|
|
|
|
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>', '')
|
|
|
|
|
2009-05-04 21:36:11 +02:00
|
|
|
if [x for x in limits if str(x).isdigit()]:
|
|
|
|
blindtest = str(tuple([x for x in limits if str(x).isdigit()]))
|
|
|
|
blindtest = blindtest.replace("L", "")
|
|
|
|
blindtest = blindtest.replace(",)",")")
|
|
|
|
query = query.replace("<gtbigBlind_test>", "gt.bigBlind in " + blindtest)
|
|
|
|
else:
|
|
|
|
query = query.replace("<gtbigBlind_test>", "gt.bigBlind = -1 ")
|
2009-05-04 21:12:41 +02:00
|
|
|
|
2009-05-08 23:41:09 +02:00
|
|
|
groupLevels = "show" not in str(limits)
|
2009-05-04 21:12:41 +02:00
|
|
|
if groupLevels:
|
|
|
|
if self.db.backend == self.MYSQL_INNODB:
|
2009-05-08 23:41:09 +02:00
|
|
|
bigblindselect = """concat('$'
|
|
|
|
,trim(leading ' ' from
|
2009-05-04 21:12:41 +02:00
|
|
|
case when min(gt.bigBlind) < 100
|
|
|
|
then format(min(gt.bigBlind)/100.0, 2)
|
|
|
|
else format(min(gt.bigBlind)/100.0, 0)
|
|
|
|
end)
|
2009-05-08 23:41:09 +02:00
|
|
|
,' - $'
|
2009-05-04 21:36:11 +02:00
|
|
|
,trim(leading ' ' from
|
2009-05-04 21:12:41 +02:00
|
|
|
case when max(gt.bigBlind) < 100
|
|
|
|
then format(max(gt.bigBlind)/100.0, 2)
|
|
|
|
else format(max(gt.bigBlind)/100.0, 0)
|
|
|
|
end)
|
|
|
|
) """
|
|
|
|
else:
|
2009-05-08 23:41:09 +02:00
|
|
|
bigblindselect = """'$' ||
|
|
|
|
trim(leading ' ' from
|
2009-05-04 21:12:41 +02:00
|
|
|
case when min(gt.bigBlind) < 100
|
|
|
|
then to_char(min(gt.bigBlind)/100.0,'90D00')
|
|
|
|
else to_char(min(gt.bigBlind)/100.0,'999990')
|
|
|
|
end)
|
2009-05-08 23:41:09 +02:00
|
|
|
|| ' - $' ||
|
2009-05-04 21:12:41 +02:00
|
|
|
trim(leading ' ' from
|
|
|
|
case when max(gt.bigBlind) < 100
|
|
|
|
then to_char(max(gt.bigBlind)/100.0,'90D00')
|
|
|
|
else to_char(max(gt.bigBlind)/100.0,'999990')
|
|
|
|
end) """
|
2009-05-08 23:41:09 +02:00
|
|
|
bigblindselect = "cast('' as char)" # avoid odd effects when some posns and/or seats
|
|
|
|
# are missing from some limits (dunno why cast is
|
|
|
|
# needed but it says "unknown type" otherwise?!
|
2009-05-04 21:12:41 +02:00
|
|
|
query = query.replace("<selectgt.bigBlind>", bigblindselect)
|
|
|
|
query = query.replace("<groupbygt.bigBlind>", "")
|
|
|
|
query = query.replace("<hcgametypeId>", "-1")
|
2010-12-10 15:31:12 +01:00
|
|
|
query = query.replace("<hgametypeId>", "-1")
|
2009-05-04 21:12:41 +02:00
|
|
|
else:
|
|
|
|
if self.db.backend == self.MYSQL_INNODB:
|
2009-05-08 23:41:09 +02:00
|
|
|
bigblindselect = """concat('$', trim(leading ' ' from
|
|
|
|
case when gt.bigBlind < 100
|
|
|
|
then format(gt.bigBlind/100.0, 2)
|
|
|
|
else format(gt.bigBlind/100.0, 0)
|
|
|
|
end
|
|
|
|
) )"""
|
2009-05-04 21:12:41 +02:00
|
|
|
else:
|
2009-05-08 23:41:09 +02:00
|
|
|
bigblindselect = """'$' || trim(leading ' ' from
|
|
|
|
case when gt.bigBlind < 100
|
|
|
|
then to_char(gt.bigBlind/100.0,'90D00')
|
|
|
|
else to_char(gt.bigBlind/100.0,'999990')
|
|
|
|
end
|
|
|
|
) """
|
2009-05-04 21:12:41 +02:00
|
|
|
query = query.replace("<selectgt.bigBlind>", bigblindselect)
|
|
|
|
query = query.replace("<groupbygt.bigBlind>", ",gt.bigBlind")
|
|
|
|
query = query.replace("<hcgametypeId>", "hc.gametypeId")
|
2010-12-10 15:31:12 +01:00
|
|
|
query = query.replace("<hgametypeId>", "h.gametypeId")
|
2009-05-28 20:54:32 +02:00
|
|
|
|
|
|
|
# Filter on dates
|
|
|
|
query = query.replace("<datestest>", " between '" + dates[0] + "' and '" + dates[1] + "'")
|
|
|
|
|
2009-05-04 21:12:41 +02:00
|
|
|
#print "query =\n", query
|
|
|
|
return(query)
|
|
|
|
#end def refineQuery(self, query, playerids, sitenos, limits):
|