From 9d9f8507532e343ca35562538c39ace90e56f5ea Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Sat, 18 Jul 2009 20:46:50 +0100 Subject: [PATCH] use Database.py in GuiPlayerStats --- pyfpdb/GuiPlayerStats.py | 28 ++++++++++++++++------------ pyfpdb/fpdb.py | 2 +- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/pyfpdb/GuiPlayerStats.py b/pyfpdb/GuiPlayerStats.py index 4ad21764..6b486c23 100644 --- a/pyfpdb/GuiPlayerStats.py +++ b/pyfpdb/GuiPlayerStats.py @@ -20,28 +20,29 @@ import pygtk pygtk.require('2.0') import gtk import os +import sys from time import time, strftime import Card import fpdb_import +import Database import fpdb_db import Filters -import FpdbSQLQueries class GuiPlayerStats (threading.Thread): def __init__(self, config, querylist, mainwin, debug=True): - self.debug=debug - self.conf=config - self.main_window=mainwin + self.debug = debug + self.conf = config + self.main_window = mainwin + self.sql = querylist + self.MYSQL_INNODB = 2 self.PGSQL = 3 self.SQLITE = 4 - + # create new db connection to avoid conflicts with other threads - self.db = fpdb_db.fpdb_db() - self.db.do_connect(self.conf) - self.cursor=self.db.cursor - self.sql = querylist + self.db = Database.Database(self.conf, sql=self.sql) + self.cursor = self.db.cursor settings = {} settings.update(config.get_db_parameters()) @@ -216,7 +217,7 @@ class GuiPlayerStats (threading.Thread): flags = [True] self.addTable(vbox1, 'playerDetailedStats', flags, playerids, sitenos, limits, seats, groups, dates) - self.db.db.commit() + self.db.commit() print "Stats page displayed in %4.2f seconds" % (time() - starttime) #end def fillStatsFrame(self, vbox): @@ -280,8 +281,10 @@ class GuiPlayerStats (threading.Thread): if column[colalias] == 'plposition': if value == 'B': value = 'BB' - if value == 'S': + elif value == 'S': value = 'SB' + elif value == '0': + value = 'Btn' else: if column[colalias] == 'game': if holecards: @@ -379,7 +382,8 @@ class GuiPlayerStats (threading.Thread): # Group by position? if groups['posn']: - query = query.replace("", 'hp.position') + #query = query.replace("", "case hp.position when '0' then 'Btn' else hp.position end") + query = query.replace("", "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: diff --git a/pyfpdb/fpdb.py b/pyfpdb/fpdb.py index 5da4b746..7d387bbc 100755 --- a/pyfpdb/fpdb.py +++ b/pyfpdb/fpdb.py @@ -446,7 +446,7 @@ class fpdb: #end def tab_bulk_import def tab_player_stats(self, widget, data=None): - new_ps_thread=GuiPlayerStats.GuiPlayerStats(self.config, self.querydict, self.window) + new_ps_thread=GuiPlayerStats.GuiPlayerStats(self.config, self.sql, self.window) self.threads.append(new_ps_thread) ps_tab=new_ps_thread.get_vbox() self.add_and_display_tab(ps_tab, "Player Stats")